The 13 Most Important Unix Commands

cd - Change the current directory.

Format      cd directoryname

Examples cd fred change subdirectory fred to the current directory cd make your home directory the current directory cd .. change to the parent of the current directory cd ~garyt change to the home directory of user garyt


cp - Copy a file

Format      cp file1 file2
            cp file1 newlocation

Examples cp fred1 fred2 copies the contents of the file fred1 to the file fred2, erasing any existing file called fred2 in the process. cp fred1 letters/ copies fred1 to the directory letters which branches off of the current directory


emacs - Edit a file using the emacs editor

Format      emacs filename

Example emacs fred opens the text file fred in an emacs window for editing. A file fred will be created if it doesn't already exist


enscript - Convert text files to POSTSCRIPT format for printing

Format      enscript filename

Examples enscript fred2 prints the contents of fred2 enscript -2r fred2 prints fred2 as landscaped, 2 pages side-by-side on each sheet


less - Display a file on the terminal. You may use arrow keys
and space bar to manuever within the text. Press 'q' to quit

Format      less filename

Example less fred displays the file fred on the terminal


lpr - Print a text file

Format      lpr filename

Example lpr fred2 prints the contents of fred2 on the default printer located in Room 272


ls - Lists the files and subdirectories in a directory

Format      ls [-alF]

Examples ls list in multi-column format ls -l list with detailed information such as permissions, file size and owner ls -al as with ls -l but also shows hidden files ls -F list in multi-column format with a / (slash) after an entry if it is a directory and an * (asterisk) if it is an executable file


man - Display manual pages (information on Unix commands)

Format      man command

Examples man cat Shows information about the cat command man -k "catenate" Gives the header lines of all manual entries that contain the text "catenate" in their header.


mkdir - Make a directory

Format      mkdir directoryname

Example mkdir letters makes a new sub-directory in the current directory called letters


mv - Changes the name of a file or its location

Format      mv oldfilename newfilename
            mv filename newlocation

Example mv fred jack if an existing file called jack exists, it is deleted and then the file fred is renamed jack mv fred images/ moves fred into sub-directory images mv fred .. moves fred into parent directory


pwd - Show the current working directory

Format      pwd


rm - Delete a file

Format      rm filename

Example rm fred deletes the file fred from the current working directory


rmdir - Remove a subdirectory (works only if it is empty)

Format      rmdir directoryname

Example rmdir letters deletes the subdirectory called letters



© Gary Thompson 1996