For those new to Linux/Unix, here are some useful commands along with some of their useful options. The brackets [ ] mean that an argument is optional. In the examples, bold type refers to commands that the user types. Unix has many more commands, and these commands have more options than those listed here. For more information use the 'man' command or the 'info' command.
| -f | Display a one-line description of the command; synonym 'whatis' |
| -k | List the man pages related to the command; synonym 'apropos' |
| -l | long listing |
| -h | print file sizes in reasonable units, not just bytes |
| -a | list hidden files (beginning with .) |
| -R | list directories recursively |
| -d | don't list contents of directories |
| -S | sort by size (use with -l for example) |
| -t | sort by time of last file modification |
| -X | sort by extension |
| -F | append a symbol to the filename depending on the file type |
| --color | use color to distinguish between types of files |
| --color=never | don't use color |
| --color=auto | use color if output is going to a terminal |
| <spacebar> | scroll forward one page |
| ^b (control-b) | scroll backward one page |
| /<text> | search for string <text> |
| n | find next occurence of string |
| N | find previous occurence of string (search for string in opposite direction)* |
| g | go to the beginning of the file* |
| G | go to the end of the file* |
| v | edit the current file with 'vi'* |
| :n | go to the next file* |
| :p | go to the previous file* |
| q | quit |
| -i | prompt user before overwriting destination file if it exists |
| -f | don't prompt user about overwriting |
| -u | if the destination file exists, overwrite it only if the source file is newer |
| -i | prompt user before overwriting destination file if it exists |
| -f | don't prompt user about overwriting |
| -u | if the destination file exists, overwrite it only if the source file is newer |
| -r or -R | copy directories recursively (copy directories and their files and subdirectories, etc.) |
| -p | preserve file attributes, such as file timestamps |
| -i | prompt user before removing the file |
| -f | don't prompt user |
| -r | recursively remove subdirectories (and their files and subdirectories, etc) - Use With Caution! |
| -P<printer> | print to the specified printer* |
| -P<printer> | show print queue for the specified printer |
| -a | lists all print queues |
| -H | Print column headings |
| -e | List all processes |
| -f | Use full format. |
| -U <user> | Select processes for user <user> |
| a | All processes on a terminal |
| u | User oriented format |
| x | Processes without a controlling tty |
Note: The full format (-f option) lists the parent process ID (PPID). The PPID of a process is the PID of the process that spawned it, which is sometimes useful to know.
| -d <delay_time> | Specify time between updates |
| -u <user> | List processes for user <user> |
| -p<PID> | List process with ID <PID> |
| -n <num_iterations> | Specify number of iterations before quitting |
| -l | List possible signals to send (that's the letter 'l' and not the number '1') |
| -15 or -TERM | Send the 'terminate' signal (the default signal) to the process* |
| -9 or -KILL | Send the 'kill' signal to the process* |
| -1 or -HUP | Send 'hang up' signal to the process (that's the number '1' and not the letter 'l') |
| -name <filename> | Search for the file <filename> |
| -type <filetype> | Search for file of type <filetype>. Some possible values of <filetype>: d=directory, l=symbolic link, f=regular file |
| -exec <command> | Execute the command given |
| -ok <command> | Like exec but prompt user before executing the command |
| -mtime <n> | Search for file modified <n> days ago. +n = more than n days ago; -n means less than n days ago. |
| -mmin <n> | Search for file modified <n> minutes ago. +n = more than n minutes ago; -n means less than n minutes ago. |
| -newer <file> | Search for file newer than <file> |
| -prune | When a match is found, do not descend into that directory. (Ignore that directory and its subdirectories.) |
| -not <expr> | True if <expr1> is false |
| <expr1> -o <expr2> | Or. If <expr1> is false, test <expr2> |
| -i | Ignore case |
| -r or -R | Search files in directories recursively |
| -v | Invert match: select nonmatching lines |
| -s | Summarize (give total for each argument) |
| -h | Display sizes in 'human readable format', using units of: B=bytes, K=kilobytes, M=megabytes, G=gigabytes |
| --exclude <pattern> | Exclude files or directories which match the given pattern |
| -l | Define the standard math library. Needed for the functions listed below. |
| sqrt( ) | Square root |
| s( ) | Sine (argument in radians) |
| c( ) | Cosine (argument in radians) |
| a( ) | Arctangent (result in radians) |
| l( ) | Natural logarithm |
| e( ) | Exponential |
| This page was last updated on 1/28/2008. |