CMSC212 ---- Quick Reference Guide for the UNIX shell commands

  1. Command-line Format
    1. Prompt           

                                                              i.      displayed to you on the screen to tell you what application you are giving a command to

                                                            ii.      the default shell on the WAM Linux machines in the class accounts is the T-shell

                                                          iii.      the default prompt on the WAM machines is of the form-           machinename:directory:

example: if the machine name is    thisone  and you are in your home directory, it would look like     thisone:~:

    1. Command

                                                              i.      the verb - typed first on the command-line

                                                            ii.      tells the shell what you would like done

    1. Options (Switches)

                                                              i.      the adverb - follows the command to which it corresponds

                                                            ii.      tells details of how you would like the command done

                                                          iii.      usually a single letter preceded by a dash

                                                          iv.      can have arguments of its own

    1. Arguments

                                                              i.      the direct object - tells the shell to whom the command will be done

                                                            ii.      the type of the argument is determined by the command

                                                          iii.      can be the name of a directory, the name of a file or another command

  1. Reference to Directories
    1. the directory structure is hierarchical starting from the root (known as /)
    2. the current working directory is the default (what is assumed) for most commands
    3. the / is used as a delimiter when typing a name that includes its location in the structure

for example   /this/that/other  refers to other which is a child of that which is a child of this which is a child of the root

    1. the beginning of that name tells where to start

                                                              i.      / means start at the root

                                                            ii.      ~ means start at a home directory (your own if no id is given or the one corresponding to the id if the ~ is followed immediately by an id)

                                                          iii.      .. means go to the parent of the current working directory

                                                          iv.      none of these means you start at the current working directory

  1. Wildcards
    1. in naming files and directories, two wildcards are the * and the ?
    2. the * replaces 0 or more characters
    3. the ? replaces 1 and only 1 character
  2. Command-line modifications
    1. <   allows you to direct the file that appears to the right of this symbol into the application specified on the left of this symbol   (example:  :~:a.out <infile    puts the contents of infile as input to the executable file named a.out rather than taking from standard input (keyboard))
    2. >   allows you to direct into the file that appears to the right of this symbol from the application specified on the left of this symbol (example: :~:this.exe > outfile  puts the output of the executable named this.exe into the file named outfile rather than to standard output (screen))
    3. |     allows you to put the output of the application to the left of this symbol through the application named on the right (example:  :~:ls -l | more   displays the output of the ls -l command to the screen one screenful at a time rather than without screen breaks)
    4. >&   redirects the standard error into the file named on the right of this symbol
    5. & after a command line indicates that that task should run in the background so you get a prompt back right away (example:   :~:emacs file1.c &        tells emacs to run in the background)
  3. Most Commonly Used Commands

 

logout

close the connection with the UNIX shell that provided the current prompt

exit

also closes the connection with the UNIX shell that provided the current prompt

cd

change to the directory named as the argument (default: your own home)

pwd

display the path from the root of the current working directory

ls

list the contents of the directory named as the argument (default: the current working directory)

ls -l

list the contents of the directory named as the argument with other information about those items (default: the current working directory)

more

display the contents of the ASCII file named as the argument

emacs

starts the emacs text editor on the file named as the argument (default: a scratch (not saved) document)

rm

remove the file named as the argument

cp

copy the item named as the first argument to the space named as the second argument

ln -s

create a symbolic link from the file or directory named as the first argument to the name given as the second argument

mv

move the item named as the first argument to the space named as the second argument

mkdir

make a new directory based on the name given as the argument

rmdir

remove a directory based on the name given as the argument

gcc

compile the file(s) given as the arguments

make

compile as directed by the Makefile provided

passwd

change the password associated with the current account

chfn

change the finger information associated with the current account

finger

give the information the user has provided about the account named as the argument

qpr

to print the file named as the arguments (options are required)

mpage

to print multiple pages on the same paper (options are required)

quota

tells the amount of space you have used and how much you have available

man

access the manual pages for the UNIX operating system of the command named as the argument