Cheat Sheet
Cheat Sheet
Options for ls -a list all files that are hidden, -d list the content of the directory, -h human readable format, -
l display result in long format, -r reverse order, -t sort by modification time. mkdir -p forcefully create the
file. For cp command -a copies everything, -i interactive prompt the user, -r recursively copies everything, -
u copy new files or non-existing files, -v display message as copy is going.
Wildcards: [characters] member of the set character, [!characters] not a member of set character, [[:class:]]
member of specified class.
File command-type of file. Touch -options, -a used to edit time and date of existing files and to check that ls
-lu filename. Less- scroll up and down, space to next, b to prev, enter to next, q to quit, /word for finding
specific. More- scroll down. Head and tail -n, default 10 lines. mv -option source dest. cp -option
source dest. The most imp option for rm is -i yes or no.
Find command- find [pathname] [-name filename], -l for symbolic link, -i will be case insensitive find and
copy at the same time -exec: find ~ / -iname_list.txt -exec cp{} ~\, find and delete- find -name dummy -exec
rm -rf {} \, you must quote a pattern or write after \. Sort command- sort -option filename, -n numeric, -r
reverse, -k number for sorting a table. Grep command- grep -option pattern filename, -i case insensitive, -c
to search and display total number, -r recursively check. Unique- uniq filename, removes duplicates. Word
count- wc -option filename, -l display number of line, -c number of byte, -w number of words.
Cut command- cut -option filename, cut -c3-5 filename- extract 3 rd to 5th character, cut -f2 filename- extract
2nd field tab as delim char., cut -d’,‘ -f2,5 filename- extract 2nd and 5th character field using , as a delim char.,.
Paste command- paste -option source > dest., paste -d ‘,’ sources > dest., -s for sequential oreder.
Files permission- b or c- device files. chmod option filename. Only owner and superuser can change the
mood. Represent 2 ways- octal and symbolic. 0-n,1-x,2-w,3-wx,4-r,5-rx,6-rw,7-rwx. -r for recursively change
perm of file and directory.
Root user is omnipotent, they can do anything. Sudo command- sudo -option command can perform as
superuser or other. ps- list programs that are running with processor ID, uname- display information of the
system, uname -a, uname -o OS. df- display system disk space outage, -k in bytes, -h human. top- display
top processor in the system. For finding info. cat /etc/passwd | grep -i ‘ ‘. whoami for your account, -
H for column heading, -u for ideal time each user, -q for list of login, -b for boot.
Man- multipage description with option and argument, ctrl z back to prompt, section specify- man 5 filename. Help-
more info. Whatis- very brief description. Info same as man but viewer is much easier. Apropos- when not sure about
the command name and use, the first field is name of man page and the second shows the section.
Umask- umask -S maskexpression, reads from right to left. Default for normal is 002 and for root 022, default for file
is 666 and for directory is 777.