UNIX Commands


Here is a slightly more detailed list of UNIX commands than the OIT page but not so mired in minutiae as to be useless. Items in square brackets [] are optional while items in slant brackets <> are descriptions of what should be placed there.
alias copy egrep/grep finger list
make dir. man more/page move password
phone print quota remove remove dir.
wildcards
make an alias:
1: alias
2: alias < alias name>
3: alias < new alias >='< string >'
Syntax-
  1. This is the syntax for listing all the currently assigned aliases
  2. This is the syntax for finding out a single alias. If the name is not an alias, nothing will be returned
  3. This is the syntax for creating a new alias. For example, to make an alias of the command vt2d that sets the display to the terminal vortex2.egr.duke.edu, type:
    > alias vt2d='setenv DISPLAY vortexc2.egr.duke.edu:0.0'
    
copy:
1: cp [-fip] < source file > < target file >
2: cp [-fip] < source files > < target dir >
3: cp -r|-R [-fip] < source dirs > < target dir >
Syntax-
  1. This is the syntax for copying a single file into a new location. If the target already exists, the new version of the source files keeps the same access list (see afs. If the target does not exist, the new file has the same ACL as the old file.
  2. This is the syntax for copying multiple files into a single directory.
  3. This is the syntax for copying directories to a new location. The -r or -R flag must be given to copy directories. In either case, all subdirectories and subfiles will be copied to the new location.

    There is a subtle difference when copying a single directory. If the target directory already exists, the source directory will be put in it. If not, the target will be created and the files from the source will be put in it. When copying multiple directories, the copies become subordinate members of the target.

Flags-
egrep/grep:
1:egrep [ -bchilnsv ] [ -e < pattern list > ] [ -f < file > ] [ < strings > ] [ < file > ]
2:grep [ -bchilnsvw ] < limited regular expression > [ < filenames > ]
Syntax-
  1. This is the egrep command, which employs a faster search algorithm but also takes up more memory than grep. It will search through a file or redirected input for something matching the pattern.
  2. This is the grep command, which is like egrep but employs a slower, less memory-intensive algorithm.
Flags-
  • -c only list how many lines have the pattern
  • -f < file >use as a pattern list the contents of file. Note that grep cannot accept a file for the pattern
  • -i ignore upper vs. lower case
  • -n show the line number in which the pattern is found
  • -v anti-grep; omit lines with pattern matches
finger:
1:finger [ -bfhilmpqsw ]
2:finger [ -bfhilmpqsw ] < username >
3:finger [ -bfhilmpqsw ] < @host >
4:finger [ -bfhilmpqsw ] < username@host >
Syntax
  1. This command lists all the users logged in to any acpub terminal
  2. This command searches for a given user on any acpub machine
  3. This command lists all the users on a particular machine
  4. This command searches for a single user on a siungle machine Flags-
    • -h suppress printing the .project file
    • -p suppress printing the .plan file
    list:
    ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ path ]
    Syntax-
    • This is the command for listing the contents of a directory. If you type ls without specifying a path, you will get a listing of the current working directory. If you specify a path which is a directory, you will get a listing of that directory. If you specify a name with wildcards, you will get listings of all the files and all the directories that match that pattern.
    Flags- (see man pages for full accounting)
    • -a all; list all entries, even the ones that start with '.'
    • -A almost all; saome as 'a' excluding the '.' and '..' directories
    • -C use multiple column format (default)
    • -F fancy; put a / after directory names, a * after executables, and an @ after links
    • -l long format; include file information, size, and modification date
    • -R recursive; list all subdirectories as they are encountered
    make directory:
    mkdir [ -m < mode > ] [ -p ] < directories >
    Syntax-
    • This command will create new directories with the paths given
    Flags
    • -m < mode > mode; this is not wholly useful for an AFS system as it allows a user to set the mode under the old system (chmod-type). See chmod for further details
    • -p this flag allows the user to create an entire directory path from scratch. It will create the intervening directories between what you want and what exists
    manual pages:
    1: man [ - ] [ -adFlrt ] [ -M < path > ] [-T < macro package > ] [-s < section > ] < names >
    2: man [ -M < path > ] -k < keywords >
    3: man [ -M < path > ] -f < files >
    Sytax
    1. This syntax will display the manual pages under a particular name
    2. This syntax will search for a keyword within all the manual pages in the path and display the lines from those manual pages with that word
    3. This syntax will display the file using the man processor
    Flags-
    • -a all; shows all man pages for a particular name (for example, there may be two pages for a certain program)
    • -f < files > file search; man will print the names of the man files for a particular file and give a brief description
    • -k < keywords > keyword search; look for any of the keywords listed and display that line of the man page. It will also print out the name of the man page in which the word was found
    • -F Force; allow only the man pages in the path given with the -M flag to be used
    • -M < path > specify an extra (or, using the -F flag, only) search path for man pages
    more/page:
    1: more [ -cdflrsuw ] [ -lines ] [ +linenumber ] [ +/< pattern > ] [ < filenames > ]
    2: page [ -cdflrsuw ] [ -lines ] [ +linenumber ] [ +/< pattern > ] [ < filenames > ]
    Syntax-
    1. The 'more' command will show a text file one screen or line at a time.
    2. The 'page' command will do the same as above but will first clear the screen.
    Flags-
    • See the man pages for the flags and for the commands available within more and page.
    move:
    1: mv [-fi] < source > < target >
    2: mv [-fi] < source files > < target dir >
    Syntax-
    1. This is the syntax for moving a single file to a new name or a different directory. If the target does not exist or is a file name, the source will be copied into the name target. If the target exists and is a directory, the source will be moved into that directory.
    2. This is the syntax for moving multiple files into a new directory. In this case, the target must be a directory. Flags-
      • -f no prompt for overwriting targets
      • -i prompt for overwriting targets
      password change:
      passwd
      Syntax-
      • This is the command to change your password. Type it in, then follow the command prompts. Note that your password must be at least eight characters long and should contain both letters and numbers. Do not make your password something someone else yould easily guess.
      phone number lookup:
      phone [ -x ] name
      Syntax-
      • This command will check the Duke White Pages for a person's phone number. There are two ways to look up a person's name:
        1. no quotes: simply typing phone firstname lastname will look up a person's name, but you have to have it exactly right.
        2. quotes: using quotation marks allows the use of wildcards. For example, to find Jay Benton (who might be a James but you're not sure), type phone "Ja* Benton" and you will get the desired result.
      Flags-
      • -x allow only exact matches (don't use this)
      off-line print:
      lpr [ -P< printer > ] [ -F< filters > ] [ < filenames< ]
      Syntax-
      • This is the syntax for printing a file to one of the public laser printers on campus.
      Flags-
      • -P< printer > select a printer. Without this flag, the file will print to a laser printer in the same room as your machine. Possible printer names are hudsonlp1, hudsonlp2, teerlp1, teerlp2, carrlp1, soclp1, etc. The printer name comes right after the P with no spaces, i.e. -Phudsonlp1
      • -F< filters > select a printing filter. PostSCRIPT files do not need a filter, while text files should be printed using the l filter. Other filters are available - check the man pages for lpr. Again, there is no space after the F
      disk quota:
      quota
      Syntax-
      • This command will show the amount of disk space used, the amount alloteted to be used, and the space remaining on the partition. If the partition space ever gets to 99%, e-mail OIT.
      remove:
      1: rm [-f|i] < files >
      2: rm -r [-f|i] < directory > [< files >]
      Syntax-
      1. This is the syntax for removing individual files
      2. This is the syntax for removing entire directories and all the files they contain.
      Flags-
      • -f remove write-protected files without prompting
      • -i prompt before removing any files
      • -r recursive; remove the given files and directories, including any subdirectories. Be very careful using this flag as you can wipe out your entire directory!
      remove directory
      rmdir [-ps] < directories >
      Syntax-
      • This command will remove the given directories if they are empty
      Flags-
      • -p remove parent directories if they become empty after deleting the named directory
      • -s suppress printing of standard error if -p is used
      wildcards
      Wildcards are replacement characters that allow multiple files to be selected with a single string. The two wildcards are:
      1. ?
        • Think of this as a blank in Scrabble. For instance, typing
           > ls f?n
          will list all directories with three letters, the first of which having to be an f and the third (and last) of which having to be an n. The second letter can be anything, so directories called fan, fun, and anything else will be listed. Directories name nofun or fawn will *not* be listed.
      2. *
        • This is also known as the "all after" wildcard. It can be replaced by any number of characters. For instance, typing
           > ls f*n
          will list all directories starting with f, ending with n, and having any characters in between. Directories named fan, fun, or fawn will be listted, but nofun will not. Try not to use two * in the same string unless divided by a period. This is mainly used for moving or copying multiple graphics files that all have the same extension (i.e. .gif o .jpg).
Go to UNIX page
Go to UNIX goals page
Go to ME 165 home page
Last updated 9/10/97 by MRG II