Unix Commands

Commonly used commands and options on Unix computers.

  The following format is used for commands:
     Italic indicates a variable that you supply
     Bold indicates exactly what you type
  To display a command description from the Unix Manual:
     man command
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Command Action Example
alias Creates a temporary name for a Unix command. alias  name command
  To remove an alias: unalias  name
bg Places a suspended job in the background.    
cat Displays a specified file. cat  file
cd Changes current directory to a different directory. cd  directory
  To change back to your home directory: cd   
 
Directory abbreviations:
~   Home directory
..   Parent directory
.    Current working directory
 
chmod Changes permission status for a file or directory. chmod  code file
chmod  code directory
  To keep a file private: chmod  600 file
  To give everyone read permission: chmod  664 file
compress Reduces the size of a file and adds .Z to the file's name. compress  file
  To restore a compressed file: uncompress  file.Z
cp Makes a copy of a file. cp  file1 file2
  To copy a file into a different directory: cp  file directory
  To inquire before overwriting an existing file: cp -i  file1 file2
diff Compares two files and displays the differences.    
fg Restarts a suspended job in the foreground.    
finger Displays user information at the specified computer. finger  userid@computer
  To change your finger entry information: chfn
fmail Displays email status for all your accounts. fmail
  To display your email forwarding address: fmail -forward
  To set your email forwarding address: fmail -to  userid@address
ftp Starts the file transfer program with a remote computer. ftp  address
grep Finds lines in a file matching a character pattern. grep -icvn  pattern file
 
-i   Ignores case
-c   Lists count of lines that contain pattern
-v   Lists all lines except those with pattern
-n   Lists line number for each found pattern
 
head Displays the first ten lines of a file. head  file
  To display the first n number of lines: head -n  file
history Displays a list of your most recent commands. history
  To repeat the nth command from the list: !  n
  To repeat your most recent command: !!
jobs Displays active jobs and their corresponding job numbers. jobs
  To start a job in the background: job  &
  To return a job to the foreground by the job number: fg  %number
  To send a running job to the background: <Control>z bg
kill Terminates a process by its process identification number. kill  pid
  To use the strongest form of the kill command: kill -9  pid
logout Ends your computer session.  
ls Lists the files and subdirectories in your current directory. ls -Fltra
 
-l   Lists long format
-t   Lists by modification time
-r   Lists in reverse order
-F   Lists file type with special character
-a   Lists all files including dot (.) files
 
lynx Starts a text-only Web browser session at UW home page. lynx
  Starts a Web browser session at a specific Web address. lynx  url
man Displays Unix Manual entry for a command. man  command
  To search Manual Index for a keyword or topic: man -k  keyword
  To set your message status to yes or no: mesg y (or n)
mkdir Creates a new directory within your current directory. mkdir  directory
more Displays a file one screen at a time. more  file
  Use <Spacebar> to scroll forward and q to quit.  
mv Moves a file to a different directory. mv  file directory
  Moves a directory to a second directory. mv  directory1 directory2
  To rename file1 as file2: mv  file1 file2
  To rename directory1 as directory2: mv  directory1 directory2
  To inquire before overwriting an existing file: mv -i  file1 file2
passwd Starts program to change account password.  
pico Starts the Pico text editor with a file. pico  file
pine Starts the Pine® electronic mail program.  
ps Displays processes and their corresponding process identification numbers.  
pwd Displays absolute pathname of current directory.  
rm Permanently deletes a file. rm  file
  To verify prior to removal: rm -i  file
rmdir Deletes an empty directory. rmdir  directory
  To verify prior to removal: rmdir -i  directory
spell Checks the spelling in a file. spell  file
  To display all fields: staffdir -full  "lastname, firstname"
telnet Starts a telnet session with a remote computer. telnet  address
vi Starts the vi text editor with a file. vi  file
w Displays a list of who is on system.  
wc Counts lines, words, and characters in a file. wc  file

Special commands and characters:

Redirection
   <    Routes input to command from file
   >    Routes output from command to file
   >>   Appends output to existing file
   |    Routes output between commands

Wildcards used in filenames
   *    Matches any number of characters
   ?    Matches one character

Control codes
   <Control>s    Suspends the screen display
   <Control>q    Restarts suspended display
   <Control>d    Signals end of file
   <Control>c    Cancels a command
   <Control>z    Suspends a process or job:
use fg to restart
   <Control>u    Clears the command line