Linux command line examples from practice with 20 commonly used commands
You don’t want to see a complete list here, but there may be a start for some of the common Linux commands.
1. Translate ASCII character set to octal, decimal, and hexadecimal
1 2 |
$ man ascii |

2. Output calendar to console
1 2 |
$ cal |

Calendar view 6 months with week number
1 2 |
$ cal -n 6 -w |
3. Edit binary hexadecimal in VIM
1 2 3 4 5 6 |
$ vi file :%!xxd .. :%!xxd -r :wq |
4. Compare two files
1 2 3 4 5 |
$ diff -w file1.txt file2.txt 2c2.3 < Jacqueline --> C. Meier > Jacqueline Mayer |
5. Find content in files recursively using find
1 2 |
$ find . -type f -print0 | xargs -0 grep "mojito" |
6. Send a file as e-mail
1 2 |
$ mail -s subject jacque@unblog.ch < notes.txt |
7. Download multiple URLs from list
1 2 |
$ cat download-urls.txt | xargs wget -c |
8. Remove duplicate lines with awk
1 2 |
$ awk '!($0 in array) { array[$0]; print }' temp |
Line output of /etc/passwd with the same uid and gid
1 2 |
$ awk -F ':' '$3==$4' /etc/passwd |
9. Conversion from Windows/DOS (CR/LF) to Unix (LF) format
1 2 3 4 5 6 7 8 |
$ sed 's/.$//' filename # Text Search and Replace $ sed -e s/dog/cat/g file.txt > file.new # Deletes all blank lines $ sed '/^$/d' filename # Deletes spaces at the end of each line $ sed 's/ *$//' filename |
10. Recursive String Search in Files
1 2 |
$ grep -r "ramsch" * |
11. How many CPMs does my computer have?
1 2 |
$ grep processor /proc/cpuinfo | wc -l |
12. View Free Memory
1 2 3 |
$ cat /proc/meminfo | grep MemFree $ free -m |
13. View active processes
1 2 3 4 |
$ ps -ef $ ps aux $ vmstat 5 10 |
14. Create directory tree (tree)
1 2 |
$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' |
15. Output Asterisk PBX Applications
1 2 |
$ asterisk -rx "show applications" | awk '{print $1}' | sed -n -e "s/:"//p |
16. Number of MTA emails identified by SPAM
1 2 |
$ cat /var/log/maillog | egrep -c '(Alert\!)|(identified spam)|(reject\:)' |
17. How long does the computer run
1 2 |
$ uptime |
18. Set time and date
1 2 |
$ date -s "Dec 12 18:30:00 2014" |
19. Who am I and the effective user ID, UID and GID output
1 2 3 |
$ whoami $ id |
20. Output list of most recently logged in users
1 2 |
$ last -a |