Important Note about UNIX Commands Information Technology Rice

Document Sample
Important Note about UNIX Commands Information Technology Rice Powered By Docstoc
					                             Information Technology
                                 Rice University                                                                   FILE SYSTEM MANIPULATION                                 (CONTINUED)
                                  June 17, 1998
                                                                                                  MAKE (OR CREATE) DIRECTORY                                                DIRECTORY ABBREVIATION
                            Document No. UNIX 1.01
                              UNIX Reference Card                                                 mkdir directory-name - create a directory called directory-name                ~                      home directory (tilde)
                                                                                                                                                                                 ~username              another user’s home directory
                                                                                                                                                                                 .                      current or working directory
USEFUL PHONE NUMBERS                                                                              LOOK AT A FILE
                                                                                                                                                                                 ..                     parent of working directory
Consulting Center - Mudd 103 (software questions)...............x4983                             more filename - display the file contents one screen at a time
Operations - Mudd Lobby (hardware problems) .....................x4989                            head filename - display first few lines of a file
                                                                                                  tail filename - display last few lines of a file                            MOVE (OR RENAME) FILES AND DIRECTORIES
LAB PHONE NUMBERS
Computing Room - Mudd 101.................................................x4982                                                                                             mv present-filename new-filename to rename a file
RAVL - 218 Anderson .............................................................x5153            PRINT A FILE                                                              mv source-filename destination-directory to move a file
Ryon - 102................................................................................x2293                                                                                                          into another directory
Mechanical Engineering - 241 .................................................x3615               setenv PRINTER printer - set the default printer                          options: -i interactive mode. Must confirm file overwrites.
Abercrombie Lab - A121 .........................................................x2613             lpr option filename - print file
Abercrombie Lab - B223 .........................................................x3379             lpq option - check status of print queue
Physics Lab- 221......................................................................x2517       lprm option - remove jobs from printer queue                              COPY FILES
                                                                                                  fpr option filename - print Fortran file
                                                                                                  options: -Pprinter - specify a printer other than the default             cp source-filename destination-filename to copy a file into another
                                                                                                                                                                                                         filename
                                                                                                                                                                            cp source-filename destination-directory to copy a file into another
                                                                                                  LIST FILES AND DIRECTORIES                                                                             directory
                                                                                                                                                                            options: -i interactive mode. Must confirm overwrites.
                                                                                                  ls directory-name - list contents of directory
                    ANATOMY OF A UNIX COMMAND
                                                                                                  options:                                                                  REMOVE (OR DELETE) FILE
command-name -option(s) filename(s) or arguments                                                        -a     list all files including invisible files
                                                                                                       -l     long list - shows ownership, permission, and links            rm filename                   to remove a file
Example:               wc -l sample                                                                    -t     list files chronologically                                     rmdir directory-name         to remove an empty directory
                                                                                                       -f     append “*” to executable file name, “/” to directory name      options: -i interactive mode. Prompt for confirmation.
The first word of the command line is usually the command name.                                         -d     list directories
This is followed by the options, if any, then the filenames, directory                                  -u     list files using time of last access instead of time of last
name/names, or other arguments, if any, and then a RETURN. Options                                            modification                                                   CHANGE FILE ACCESS PERMISSIONS
are usually preceded by a dash and you may use more than one option                                    -F     mark directories with forward slash, mark executables with
per command.                                                                                                  an @-sign.                                                    chmod [ who op permission ] filename
                                                                                                       -g     lists ownership of each file or directory                      who can be any combination of:
The examples on this reference card use bold case for command                                                                                                                                              u (user)
names and options and italics for arguments and filenames.                                         pwd -display the name of present working directory                                                       g (group)
                                                                                                                                                                                                           o (other)
               Important Note about UNIX Commands                                                                                                                                                          a (all) (i.e. ugo)
                                                                                                  CHANGE WORKING DIRECTORY
UNIX commands are case sensitive. Type commands exactly as                                                                                                                  op adds or takes away permission, and can be:
shown; most UNIX commands are lower case. File and directory                                      cd                           to change to your home directory                                            + (add permission),
names can be lower, upper, or mixed case but must be typed exactly as                             cd directory-name            to change to another directory                                              - (remove permission), or
listed.                                                                                                                                                                                                    = (set to exactly this permission).
                                                                                                  examples:
                                                                                                  cd ~                         change to home directory                     permission can be any combination of
                                                                                                  cd test                      change to directory test                                                    r    (read)
                         ON-LINE DOCUMENTATION                                                                                                                                                             w (write)
                                                                                                                                                                                                           x (execute)
whatis command - display a one-line summary about command
man command - display on-line manual pages about command                                                                                                                    Example: chmod a+x filename - makes filename executable by
                                                                                                                                                                                                    everyone
                            SHELL TOOLS                                                                PROCESS CONTROL                                                     PROGRAM COMPILATION

Wild Cards                                                                 PROCESS STATUS                                                                 f77 filename.f        FORTRAN compiler
?                           single character wild card                     ps - display the status of the current processes                               cc filename.c         C compiler
*                           arbitrary number of characters                 options:                                                                       pc filename.p         Pascal compiler
                                                                                       -a include information about processes owned by other users        options:
HISTORY: COMMAND REPETITION                                                            -g display all processes                                           -o filename           direct output of program to filename
                                                                                       -u display user-oriented processes                                 -l library           include library in program compilation
history               display list of most recent commands                             -x include processes with no controlling terminals
!!                    repeat the entire last command line at any point                 -gx display all of your local processes                                       USER INFORMATION AND HELPFUL
                       in the current command line                                                                                                                            COMMANDS
!$                    repeat the last word of previous command             kill id-number - terminate a process owned by you
                      line at any point in current command line            id-number (PID-Process ID) can be found by first using the ps command.          env               lists your environment settings
!: n                  repeat the nth argument from previous                                                                                               who               lists users on the local system
                       line at any point in current command line           RUN COMMAND IN BACKGROUND: JOB CONTROL                                         finger username@host.domain looks up information on an
!^                    repeat first argument from previous command                                                                                                            other user
                      line at any point in the current command line        To run a command in the background, as opposed to the more common method
!n                    repeat command line n                                of running commands in the foreground, append an & to the end of a command     whois username     display real name of user
!!:p                  display previous command                             string. Then, you can type more commands to the command prompt, or even        clear              clears screen
!string               command beginning with string                        run more commands in the background for simultaneous command execution.        leave              reminds you when you have to leave
!*                    repeat all arguments to previous command                                                                                            ntalk username@host.domain talk to another user
                                                                           Control-Z                    stop (interrupt) foreground job                   lprloc             shows names and locations of printers
COMMAND I/O                                                                jobs                         list of background jobs                           stty sane          resets terminal characteristics to a
>                     command output redirection (create new)              bg                           run a stopped job in the background                                  usable set
>>                    command output redirection (append)                  fg                           resume stopped job in the background              stty               display terminal characteristics
<                     command input redirection (from file)                                                                                                date               displays current time and date
<<                    command input (from script or standard input)                                    FILE OPERATIONS                                    cal year           for yearly calendar
                                                                                                                                                          cal month-year     for monthly calendar
ALIAS                                                                      SEARCH FOR PATTERNS IN FILES                                                   tn3270 ricevm1     full-screen remote login to mainframe
alias alias-string command-string                                                                                                                         tn3270 library     full-screen remote login to Fondren
                                                                           grep search-string filename [filename...] to find and type out lines containing                      Library Card Catalog. At the VM/SP
Alias abbreviates a command string with an alias string. For multi-com-    the string in a file                                                                               screen, press the RETURN key, and then
mand strings, enclose commands in quotes.                                                                                                                                    enter dial libris after the screen clears.
                                                                           options: -v type out lines that don’t contain the string (invert the search)                      Hit RETURN again. To exit the LIBRIS
Example: alias shut chmod go-rwx                                                                                                                                             system, enter CONTROL-] (Hold down
                                                                           COUNTING WORDS IN A FILE                                                                          the CONTROL key, and type
To use the new aliased command shut on a file, and turn off read, write,                                                                                                       the close bracket character), and then
and executable permissions for all users except yourself, type shut file-   wc filename(s) counts the number of words, lines, and characters in a file                          enter close at the TN3270 prompt.
name.
                                                                           COMPARE FILES                                                                  rlogin host.domain   log into remote host computer

                                                                           diff filename1 filename2 compares contents of filename1 and filename2 on a         telnet host.domain   user interface to a remote system
                  WINDOWING ENVIRONMENTS
                                                                           line-by-line basis
                                                                                                                                                          whereis command      locate a command; display its pathname
openwin          enter the Open Windows window environment (not            FILE TRANSFER
                                                                                                                                                          spell filename        report spelling errors
                 available on X terminals)
                                                                           mail address sends mail to user at address                                     ispell filename       interactive spell-checker
startx           enter the X window environment (not required on X
                                                                           address format is user@host.domain                                             echo $path           inspect your search path
                 terminals)
                                                                                                                                                          pacinfo              displays your current printing charges
startx -m        enter the Motif window environment (to
                                                                           ftp host.domain use file transfer protocol to connect to remote host computer                        (IS systems only)
                 enter Motif from the login window of an X terminal,
                                                                           Type ? for commands                                                            bc                   basic calculator
                 type your userid, RETURN, your password and then
                                                                                                                                                                               (Control-D to exit)
                  F4)
                                                                           COMPRESS FILES                                                                 du                   display the number of disk blocks used
                                                                                                                                                                               per directory or file
                                                                           compress filename             compress file and rename it filename.Z              du -s                display your total disk usage
                                                                           uncompress filename.Z         uncompress file and rename filename                 quota -v             display your disk quota and usage