Basic UNIX Commands
=======================
Note: Whatever is in parentheses in the table below are examples
| COMMAND | FORMAT | DESCRIPTION |
| man | man [command] | Provides information on a specific command. |
| e.g.: | man man | (Provides information on the man command.) |
| man cp | (Provides information on the cp command.) | |
| ls | ls | Lists the contents, such as the files and subdirectories, in a directory. |
| e.g.: | ls | (Lists all files and subdirectories in the current directory.) |
| ls -l | (Lists all files and subdirectories in the current directory in the long format, giving information about mode, number of links, owner, group, size in bytes, and time of last modification.) | |
| pwd | pwd | Displays the current working directory. |
| e.g.: | pwd | (Displays the current working directory the user is in.) |
| mkdir | mkdir [directory or path] | Creates a directory. |
| e.g.: | mkdir mydirectory | (Creates a directory called mydirectory below the current directory.) |
| cd | cd [directory or path] | Changes the current working directory. |
| e.g.: | cd newdirectory | (Moves to the directory newdirectory which is below the current directory.) |
| cd /mydir1/mydir2 | (Moves to the directory mydir2 which is below the directory mydir1 which in turn is under the current directory.) | |
| cd | (Moves to the home directory; the directory where the user is placed when he/she logs in.) | |
| cat | cat filename | Lists the contents of the file called filename. |
| e.g.: | cat myfile | (Lists the contents of myfile.) |
| pr | pr filename | Lists the contents of the file called filename in a formatted fashion - page headers and numbers. |
| e.g.: | pr myfile | (Lists the contents of myfile in a formatted fashion - page headers and numbers.) |
| lpr | lpr filename | Prints a file, called filename, on the line printer. |
| e.g.: | lpr myfile | (Prints myfile on the line printer.) |
| rm | rm filename | Deletes a file called filename. |
| e.g.: | rm example.file | (Deletes the file called example.file.) |
| rmdir | rmdir directoryname | Deletes a directory called directoryname. |
| e.g.: | rmdir sample.dir | (Deletes the directory called sample.dir.) |
| cp | cp filename1 filename2 | Copies the contents of a file to another file. |
| e.g.: | cp example sample | (Copies the contents of the file example to sample.) |
| mv | mv oldfile newfile | Renames a file; moves the contents of the old file to the new file. |
| e.g.: | mv myfile1 myfile2 | (Changes the name of the file from myfile1 to myfile2.) |
| mv olddirectory newdirectory | Renames a directory; moves the contents of the old directory to the new directory. | |
| e.g.: | mv mydir1 mydir2 | (Changes the name of the directory from mydir1 to mydir2.) |
| pine | pine | Invokes screen oriented mail program. |
| elm | elm | Invokes screen oriented mail program. |
| date | date | Displays the current date and time. |
| ps | ps | Shows the status of the job processes in the system. |
| passwd | passwd | Changes your password. |
| kill | kill PID | Terminates a job process which is represented by a Process IDentification (PID) number. |
| e.g.: | kill 46 | (Kills or aborts job process 46.) |
| who | who | Lists all the users who are currently using the system. |
| logout | logout | Leaves the system that you are in. |
| CTRL-s | CTRL-s | Pauses the display of information on the terminal screen. (Hold down the CTRL key and press the s key.) |
| CTRL-q | CTRL-q | Resumes the display of information on the terminal screen. (Hold down the CTRL key and press the q key.) |
| CTRL-c | CTRL-c | Aborts the execution of the current command. (Hold down the CTRL key and press the c key.) |
Metacharacters
Metacharacters are certain characters that have a special meaning in Unix.
| CHARACTER | DESCRIPTION | EXAMPLE |
| * | Matches all or any string of characters | ls * |
| ? | Matches any single character | ls chart? |
| & | Places the command as a task in the background process | grep word myfile& |
| ; | Allows multiple commands to be issued on a single line | cd;pwd;ls -al |
| \ | Turns off the special meaning of a metacharacter | grep \* trial |
| < | Redirects the input of a command from a file | mail boss < report |
| > | Redirects the output of a command into a file | spell memo > misspell |
| | | Directs the output from one command to be the input of the next command | pr myfile | lpr |