Basic Unix commands

    User identification
     -------------------
 
     (Command)                   (Result)
 
     hostname                    Displays name of current machine.
 
     who                         Lists users who are logged on to current
                                 machine.
 
     whoami                      Returns current username (you).
 
     finger [option] [username]  Returns information about [username].
 
     finger -l joe               Shows long listing of user "joe".
 
     Directory manipulation
     ----------------------
 
     (Command)                   (Result)
 
     pwd                         Prints the present working directory, i.e.,
                                 prints the absolute pathname of current
                                 directory
 
     ls [option] [directory]     Lists files in [directory] (or current
                                 directory, if no [directory] given).
 
     ls                          Lists all normal, (i.e., non-hidden)
                                 files in current directory.
 
     ls -a                       Lists all files in current directory,
                                 including "hidden" files.
 
     ls -l                       Displays long listing of normal files in
                                 current directory, including file sizes
                                 and permissions.
 
     ls -al                      Combination of previous options.
 
     ls -l letters               Displays long listing of normal files in
                                 the directory called "letters"
 
     cd [directory]              Changes directory -- i.e., makes
                                 [directory] current.
 
     cd letters                  Makes the directory "letters" current.
 
     cd ..                       Makes the parent of the current
                                 directory current.
 
     cd                          Makes your home directory current.
 
     mkdir [directory]           Creates a directory called [directory].
 
     rmdir [directory]           Removes directory called [directory].
 
     who                         Lists users who are logged on currently.
 
    File manipulation            
     -----------------           
 
     (Command)                   (Result)
 
     more [file]                 Lists contents of [file] with pause
                                 between pages.
 
     more office todo            Lists contents of files "office" and
                                 "todo", pausing between pages.
 
     head [file]                 Lists the first few lines of [file].
 
     tail [file]                 Lists the last few lines of [file].
 
     rm [file]                   Deletes (removes) [file].
 
     rm -r [directory]           Recursively removes [directory] and all
                                 of its subdirectories and files.  Use  
                                 extreme caution when using this command!
 
     cp [source] [target]        Copies the contents of [source] file to
                                 [target] file.
 
                                 If [target] file exists, its data will
                                 be replaced by that in [source] file.
 
                                 If [target] file does not exist, then it
                                 will be created containing the data in
                                 [source] file.
 
                                 [target] may be a directory, in which  
                                 case a copy of [source] file will be
                                 placed in the directory [target].
 
     cp myletter letterdir       Creates "myletter" in the directory
                                 called "letterdir"
                                 
     mv [source] [target]        Moves contents of [source] file to 
                                 [target] file, then removes [source] file.
 
                                 If [target] exists then its data will be
                                 replaced by that in [source].
 
                                 If [target] does not exist then [source]
                                 will be renamed [target file].
 
                                 [target] may be a directory, in which
                                 case [source] file will be moved into
                                 that directory.
 
     mv myletter theletter       Renames "myletter" as "theletter"
 
     mv myletter letters         Where "letters" is a directory, will
                                 move "myletter" into "letters".
 
     cat [file]                  Displays contents of [file]
                                 continuously. 
 
     cat joe                     Displays contents of "joe" to standard
                                 output device.
 
     tail [file]                 Lists the last few lines of [file].
 
     cat [file] [file] ...       Creates an output file that is the 
     [file] > [file]             combination of all of the input files.
 
     rm -r [directory]           If output file exists, it will bend all
                                 replaced.
                                 
     cat part1 part2 > whole     Creates a file "whole" that is a
                                 combination of the files "part1" and to
                                 "part2".
                                 
     cat > [file]                Creates a file consisting of input from
                                 the keyboard.  (Hold down the Control 
                                 key and type a "d" to terminate input.)
     cat > temp                  Creates a file "temp" containing the
     hello there                 data "hello there".
     ^D                          
 
     cat >> [file]               Appends input from the keyboard to file.
                                 (Hold down the Control key and type a
                                 "d" to terminate input.) 
 
                                 If file does not exist it will be  
                                 created.
                                 
     cat >> temp                 Appends a line consisting of the words
     last line                   "last line" to the file "temp".
     ^D                          
 
     grep [option] '[string]'    Returns every line of [file] which    
     [file]                      contains the character string [string].
 
     grep 'Lee' folks            Where the file "folks" contains
 
                                 Jane Doe 103
                                 Lee Kramer 33
                                 Mike Randolph 11
                                 Jane Krulee 94
                                 Tom Selles 34
                                 
                                 would return
 
                                 Lee Kramer 33
    
     grep -i 'lee' folks         The "-i" option makes grep case-
                                 insensitive, so this command would
                                 return:
 
                                 Jane Krulee 94
                                 Lee Kramer 33
 
     sort [options] [file]       Sorts lines of [file].
 
     sort folks > list           Puts sorted version of the file "folks"
                                 into the file "list":
 
     rm -r [directory]           Mike Randolph 11xists, it will bend all
                                 Tom Selles 34
 
     sort +1 folkst2 > whole     Sorts the file "folks" according to the
                                 SECOND word ("+1") in each line: and to
                                 "part2".
 
     sort +2rn folks             Sorts the file "folks" in reverse order.
                                 ("r") according totrol THIRD word ("+2")
                                 in each line, which is to be interpreted
                                 as a numeric value ("n"):
                                 Jane Doe 103 
                                 Jane Krulee 94
                                 Tom Selles 34
                                 Lee Kramer 33
                                 Mike Randolph 11
     Miscellaneous 
     -------------               
 
     (Command)                   (Result)
 
     date                        Display today's date and the current
                                 time.
                                 
     mail [user] < [file]        Mail [file] to [user].
                                 
     passwd                      Change your password.
                                 
     logout                      Exit the system.
                                 
     Fps                          Display a list of all your processes
                                 (i.e., running programs).
                                 
     [command] &                 Start [command] as a "background"
                                 process, returning to system prompt
                                 immediately.  
                                 
     [command] > [file]          Save output of [command] in [file].
 
     [command] >> [file]         Append output of [command] to [file].
 
     [command1] | [command2]     Feed output of [command1] as input into
                                 [command2] ("pipeline").
 
     man [command]               Read on-line reference manual page for
                                 [command]. 
 
     rm -r [directory]           Remove the [directory] and all of its
                                 subdirectories.
                                 
     For more information
     --------------------
 
     The following Unix documents are available for 2-hour checkout
     from the EECS Computing Facilities Office, Tech rm. B626:
 
          Getting Started with SunOS (Sun Microsystems)
 
          Introducing the Unix System (McGilton and Morgan)
 
 
 
______________________________________________________________________________
                                 
          Based on "A Summary of Basic Unix Commands," by Travis
     Seymour, 1991.