University of Vermont

cems
College of
ENGINEERING AND MATHEMATICAL SCIENCES

Advanced Unix Commands

More information on almost all of the commands that follow can be found in the online manual. At the command line, type "man command-name", where command-name is the command you wish to search, e.g., mkdir.

Or go to Basic Unix Commands.

Files

  • Compressing / Uncompressing: compress, uncompress, gtar, tar, gzip, gunzip

  • Nroff/Troff files : Vroff, nroff, Xroff

  • Viewing and Printing, TeX and LaTeX files : Dvi, latex


    Processes

  • Run two or more jobs at once : &, bg, fg
  • Run a big job with low priority : nice
  • Graphically display processes running : gr_top
  • Suspend a job : [CTRL]-z
  • Kill a job : [CTRL]-c , kill
  • copy files while filtering with given script : sed
  • search file for pattern : awk, grep


    Redirection

  • Take output from one job and
    make it the input to another job:
    |, , >


  • Colors

  • editing colormaps : bitmap
  • view a color based on decimal values (on SGI"s) : cedit

  • |
    Pipe symbol - send the output of one process into another process. For example, the "ls -l" command prints out all of the files in the current directory, along with information about those files, and the "more" command displays only one screenful of information at a time. If there are a lot of files in the current directory, you might want to try "ls -l | more", which makes "ls -l" send all of it"s output to "more" which then displays it one screenful at a time. Another useful one is "ps -ef | grep USERNAME", replacing USERNAME with the user you"re looking for: it will only show the lines with that user in them.
    > filename
    Redirect output to a file. This symbol will send the output of a command to the specified file. For example, "ls -l > names.dat" will put the names and permissions of all the files in the local directory into a file named "names.dat". If you don"t want to see any output from a command, you can send the output to "/dev/null" ( "ls -l > /dev/null" would send the names to "/dev/null", though it doesn"t really serve a purpose in this example ).
    < filename
    Redirect input from a file. This symbol will take everything in the file and send it to a process as if it came from the standard input ( usually the keyboard ). For example, the "spell" program reads from standard input and prints out the words that it thinks are misspelled. So, you can type "spell<RET>", then type in the words that you want to check followed by <CTRL>-D ( the end of file mark ), and spell will print out the misspelled words. If you wanted to check all of the words in a file, you"d redirect the standard input to come from the file "spell < filename", and spell would read the file instead of the keyboard.
    &
    Make a process run in the background automatically. The process must not need input from the keyboard or output to the screen. Say the process is "cat file1 file2 > file3" and the that file1 and file2 are large. This could take a while before it finishes. To make it run in the background ( which will allow you to continue to work while it is running ), the easiest thing to do would be to use the "&", like so: "cat file1 file2 > file3 &".
    %#
    Part of the process control available under the csh shell. "%#" ( where "#" is replaces with a job number ) will re-enter a suspended process. If you use "jobs" to find the processes that you have suspended or are running in the background, what you get back might look like the following:
    
        [1] 21998 Suspended emacs useful.tex
        [2] - 22804 Suspended (signal) elm
        [3] + 22808 Suspended badb

    Where the first number ( in brackets ) is the job number, and typing "%1" at the command line would cause you to re-enter the emacs job.

    [CTRL]-c
    Part of the process control available under the csh shell. <CTRL>-C sends a termination signal to current process. This usually kills the current process.
    [CTRL]-z
    Part of the process control available under the csh shell. <CTRL>-Z sends a terminal stop signal to the current process. This allows you to temporarily exit a running process, and re-enter it with "fg". The "jobs" command will show you what processes you have done this to. If the process doesn"t require input from the keyboard or output to stdout ( usually the screen ), then after using "<CTRL>-Z" you can make the process run in the background with "bg".
    Dvi {-Pprintername}filename.dvi
    Dvi prints out "filename.dvi" files, which are produced by the TeX and LaTeX text processing programs. More information on TeX and LaTeX can be found in the printed manuals, available for borrowing at the EM computer facility. "-Pprintername" tells Dvi which printer to print out on. This parameter isn"t necessary if you"ve set your "PRINTER" environment variable (do this with the "setenv" command ).
    Vroff filename
    Vroff is an X-windows previewer for documents that use the nroff/troff text processing commands. For more information, look in the document formatting portion of the printed manuals in room 252 - the "Nroff/Troff User"s manual" and the "Troff Tutorial" are both worth looking at.
    Xroff {-Pprintername}filename
    Xroff prints out documents that use the nroff /troff text processing commands. For more information, look in the document formatting portion of the printed manuals in Votey Hall, Rm. 252 - the "Nroff/Troff User"s manual" and the "Troff Tutorial" are both worth looking at. "-Pprintername" specifies which printer to send the print job to ( i.e. -Pcolorlaz ). This parameter isn"t necessary if you"ve set your "PRINTER" environment variable ( do this with the "setenv" command ).
    awk
    Pattern scanning and processing language. Very useful for making text filters. "awk" can run it"s own script files ( "awk -f scriptfile inputfile" would run the script file on the input file ), or it can accept quick scripts on the command line - "awk "length < 80" filename" prints to stdout ( usually the screen ) all of the lines in the file "filename" that are shorter than 80 characters.
    bg
    Background a stopped job. If you start a process that doesn"t require input from the keyboard or output to the screen, then you can make it run in the background. Say the process is "cat file1 file2 > file3" and the that file1 and file2 are large. This could take a while before it finishes. If you start the process, and then realize that you want to make it run in the background ( which will allow you to continue to work while it is running ), type "<CTRL>-Z" and then "bg". The process is now backgrounded. You can see the status of the job with "jobs" or "ps".
    bitmap {filename}
    X-windows bitmap viewer/editor. Bitmaps can be used for X-window icons and backgrounds. (best if run from SGI machine, and SUN server (tyr, freyr)
    cedit
    X-windows color viewer. Shows what color a particular decimal value of RGB looks like. Runs from SGI machines.
    compress {filename}
    Reduces the size of the named file using adaptive Lempel-Ziv coding. Whenever possible, each file is replaced by one with the extension ".Z", while keeping the same ownership modes. If "filename" isn"t specified, compress will compress its standard input.
    etags
    Creates a tags file for use with emacs and epoch. A tags file gives the location of functions and type definitions in a group of files. Emacs and epoch use entries in the tags file to locate and display a definition. To go to a function definition in emacs, type "M-." ( Meta period ). This will ask you the name of the function that you wish to find. Type it in and press return. If what you typed in is found at the beginning of a number of functions, you might not get the correct one on the first try. If this is the case, keep typing "M-," ( Meta comma ) until you reach the one that you want.
    fg {%jobnumber}
    Run a currently backgrounded process in the foreground. If you use "jobs" to find the processes that you have suspended or running in the background, what you get back might look like the following:
    
        [1] 21998 Suspended emacs useful.tex
        [2] - 22804 Suspended (signal) elm
        [3] + 22808 Suspended badb

    Simply typing "fg" at the command line will put you back in the process that has the "+" in the 2nd column, in this case it would be the "badb" process. "fg %2" will put you back in the "elm" process.

    grep {string}{-e expression}{filename(s)}
    Along with egrep and fgrep, grep is used to search files for a string or a regular expression. If no "filename" is given, grep searches it"s standard input for the the string or expression. When grep finds the requested string or expression, it prints out the line that contains it along with the filename of the file that the line is from. Example: "grep chance *" will search all of the files in the current directory for the word "chance".
    gtar
    GNU project"s version of "tar". gtar"s command line parameters are similar to those of tar. gtar has the added advantage of not trying to keep the original file ownership of files being extracted. All files are changed to belong to the person doing the extraction. To create an archive, you might type "gtar cvf archname file1 file2 file3", which would put file1-3 in the archive named archname. "c" of "cvf archname" in the command line means create the named archive, "v" means verbose - print names of the files and the operation performed on them, and the "f archname" gives the name of the archive that you want to do the operations on. "gtar tvf archname" will print out the names of all of the files in the archive, "gtar xvf archname" will extract all of the files from archname, and "gtar xvf archname filename" will extract only "filename" from the archive, provided that it is in the archive in the first place.
    kill -9 {PID}{%job-number}
    Terminates a process with the process id of PID or the specified job number. See "jobs" and "ps" for information on how to find PID"s or job numbers. So, if the PID is 12345, then "kill -9 12345" will kill the job. If the job number is 5, then "kill -9 %5" will kill it.
    latex filename.tex
    LaTeX is a text processing language ( a superset of the TeX language ), and "latex" compiles this language into a device independent (dvi) representation of the resulting document. "latex" will report errors and, if there are none, give you a file named "filename.dvi". This file can be previewed with "xdvi", and may be printed out with "Dvi". More information on the LaTeX language is available in the LaTeX manual which you can borrow from a CEMS counselor.
    nroff {filename}
    "nroff" and "troff" are text processing languages. The "nroff" program is an ASCII previewer for nroff/troff files, showing what the file will look like when it is printed ( prints to stdout - usually the screen ). This can be handy for looking at nroff/troff files that you are writing "nroff filename | more", or for looking at the manual pages that come along with software that you get from the Internet "nroff -man filename | more". "Vroff" is a graphical previewer of nroff/troff files that will show different fonts and point sizes ( which the nroff program won"t ).
    nice {command}
    Runs a {command} with low priority so others dont experience "lagg-time".
    popd
    Removes the top directory from the directory stack, placing you into the new top directory. Use pushd to place new directories on the stack. If the stack consists of the following ( leftmost is the top of the stack ): "/usr / /usr/local/bin", then you will be in the "/usr" directory, and typing popd will make the stack look like this: "/ /usr/local/bin", putting you in the root directory ( / ).
    pushd {directory}
    Pushes "directory" on to the directory stack, placing you into that directory. If "directory" isn"t specified, pushd swaps the two top directories on the stack, placing you into whichever directory is now on the top of the stack. Use popd to remove stack entries. If the directory stack looks like this ( use "dirs" to print out the current directory stack, and the leftmost directory is top of stack): "/ /bin", and you type "pushd /usr/local/bin", then the new stack looks like this: "/usr/local/bin / /bin", and you will be in the /usr/local/bin directory. If you then type "pushd", the stack will look like this: "/ /usr/local/bin /bin" and you will be in the root directory. Finally if you type "pushd +2" the stack will look like this: "/bin / /usr/local/bin", and you will be in the /bin directory.
    sed {-e script}{-f scriptfile}{filename}
    Stream editor. Useful for making text filters. "sed" can take its instructions from a file ( -f scriptfile ) or the command line ( -e script ). For example "sed -e "s/test/testing/g" filename" will replace every instance of the word "test" with the word "testing" and print the result to stdout ( usually the screen ).
    sort {options}{filename}
    Sorts the input lines alphabetically by default, numerically if given the "-n" command line option. Without a "filename", sort works on the standard input. Otherwise it sorts the lines in the file and writes the sorted output to stdout ( usually the screen ).
    tar
    Creates tape archives, plus adds to, and extracts files from tape archives. Sometimes has permission problems when extracting files by maintaining the ownership of the files in the archive. If you have this problem, try "gtar". To create an archive, you might type "tar cvf archname file1 file2 file3", which would put file1-3 in the archive named archname. "c" of "cvf archname" in the command line means create the named archive, "v" means verbose - print names of the files and the operation performed on them, and the "f archname" gives the name of the archive that you want to do the operations on. "tar tvf archname" will print out the names of all of the files in the archive, "tar xvf archname" will extract all of the files from archname, and "tar xvf archname filename" will extract only "filename" from the archive, provided that it is in the archive in the first place.
    uncompress filename.Z
    Uncompresses files that have been compressed with the "compress" command (which automatically adds the ".Z" to the end of the filename).
    uudecode filename
    Decodes files that have been encoded with the "uuencode" command. "uuencode" changes binary files into ascii files so that they can be easily e-mailed or posted to the news.
    uuencode {source-file}file-label
    Converts a binary file into an ASCII-encoded representation that can be sent using mail(1) or posted to a news-group. If you don"t specify "source-file", then uuencode takes its input from standard-input. "uuencode" sends the encoded output to stdout ( usually the screen ). When decoded using "uudecode" the resulting file will be named "file-label".