UNIX Cheat Sheet
Directories ls ls -l pwd cd cd dir List files in current directory List in long format Print working directory name Change to home directory Change to dir Current directory is . Directory above is .. Create directory dir
mkdir dir Files mv source1 ... destination cp source1 ... destination rm file rm -r dir Miscellaneous Commands man command less file wc file chmod rights file
Move or rename one or more files Copy one or more files Remove (delete) file Remove directory dir recursively
Show manual page for command Print file to screen in pages Count lines, words, and characters in file Change permissions on file Examples of rights: a+r All can read u+rwx User can read, write, and execute a-w Nobody can write
Power Tools *
command > file command < file command | filter
Matches 0 or more characters Example: rm *.class Run command, but store the output in file instead of printing it to the screen Example: cal > thismonth.txt Run command, but get input from file instead of from the keyboard Example: a.out < testcommands Run command, but pipe the output through filter before returning output Example: ls -l | grep pdf