Professional Documents
Culture Documents
Linux Bash Shell Cheat Sheet: (Works With About Every Distribution, Except For Apt-Get Which Is Ubuntu/Debian Exclusive)
Linux Bash Shell Cheat Sheet: (Works With About Every Distribution, Except For Apt-Get Which Is Ubuntu/Debian Exclusive)
com
(works with about every distribution, except for apt-get which is Ubuntu/Debian exclusive)
Legend:
find = the best file search tool (fast) With regular expressions:
find -name “<fileName>”
find -name “text” = search for files who start with the word text grep -E ^<text> <fileName> = search start of lines
find -name “*text” = “ “ “ “ end “ “ “ “ with the word text
grep -E <0-4> <fileName> =shows lines containing numbers 0-4
Advanced Search: grep -E <a-zA-Z> <fileName> = retrieve all lines
with alphabetical letters
Search from file Size (in ~)
find ~ -size +10M = search files bigger than.. (M,K,G) sort = sort the content of files
sort <fileName> = sort alphabetically
Search from last access sort -o <file> <outputFile> = write result to a file
find -name “<filetype>” -atime -5 sort -r <fileName> = sort in reverse
('-' = less than, '+' = more than and nothing = exactly) sort -R <fileName> = sort randomly
sort -n <fileName> = sort numbers
Search only files or directory’s
find -type d --> ex: find /var/log -name "syslog" -type d wc = word count
find -type f = files wc <fileName> = nbr of line, nbr of words, byte size
-l (lines), -w (words), -c (byte size), -m
More info: man find, man locate (number of characters)
sleep = pause between commands jobs = know what is running in the background
with ';' you can chain commands, ex: touch file; rm file
you can make a pause between commands (minutes, hours, days) fg = put a background process to foreground
ex --> touch file; sleep 10; rm file <-- 10 seconds ex: fg (process 1), f%2 (process 2) f%3, ...
Linux Bash Shell Cheat Sheet
Basic Commands