UNIX QUICK REFERENCE MANUAL
------------------------------------------------------------------------------

General Command format:

    % commandname  options  arguments
    ^
    |
    +------the shell prompt

    options usually begin with a dash, but may begin with +.  Often they are
    single letters, but occasionally a single letter concatenated to a number
    or even followed by a blank and then a word or a number.  Very inconsistent.
    Read man pages or look at examples.

    arguments are usually file or directory names, but may be numbers or other
    items, like usernames or character strings.

To interrupt a program or command:

    ^c  (control c)   <-- kills running program
    ^z  (control z)   <-- this causes the job to be stopped, not killed

To logout out:

    % logout

Shells:

    Cshell:         % csh          standard prompt is %
    Bourne Shell:   $ sh           standard prompt is $

To change the prompt:

    set prompt="hiya> "            enclose in quotes

Making sure UNIX knows what kind of terminal you are using:

    set term=vt100              <-- standard, "dumb" terminal
    setenv TERM vt100

Commands for files:  (shell prompt omitted)

    cat myfile              (display)
    less myfile             (display one page at a time)
    rm myfile               (remove or delete)
    mv myfile newfile       (rename to "newfile")
    ed myfile               (edit file, line editor)
    vi myfile               (edit file, visual full-screen editor)
    emacs myfile            (edit file, another full-screen editor)
    cp myfile newfile       (copy file)
    chmod o+rx myfile       (make a file public for all to read, not write)
    chmod o-rwx myfile      (make a file secret, only you can read it)
    file myfile             (find out type of contents of file)
    lpr -Psp myfile         (print file out on Sparc printer)
    wc myfile               (word count, how many lines, words and bytes in it)
    spell myfile            (run the spelling checker on the file)
    sort myfile             (sort the contents of the file)
    cmp file1 file2         (compare 2 files)
    head somefile           (display first 10 lines of file)
    tail somefile           (display last 10 lines of file)
    strings somefile        (clean out unprintable characters)
    tr a-z A-Z somefile     (translate characters in somefile (lower to upper))
    grep UNIX somefile      (find all occurrences of string "UNIX" in file)

Commands for directories:  (shell prompt omitted)

    ls                      (list all files in current directory)
    ls -l                   (long output listing)
    pwd                     (print working directory)
    cd somedir              (change directory into somedir)
    cd ..                   (go up to parent directory)
    cd /                    (go to the root directory)
    cd                      (go to your home (login) directory)
    mkdir somedir           (make a directory)
    rmdir somedir           (remove a directory, must be empty)
    pushd somedir           (temporarily go to somedir, may be anywhere)
    popd                    (return to previous directory)

Compilers:

    cc someprog.c           (Compile C program)
    a.out                   (run compiled C program)
    lint someprog.c         (check C program for errors, don't compile)
    dbx a.out               (run the C debugger on a.out)
    pc someprog.p           (compile Pascal program)
    g++ someprog.c          (compile C++ program)
    adacomp -n mainprog.a   (compile Ada program)
    adabind                 (bind or link Ada program)
    adaexec                 (execute Ada program)
    ibcl                    (start the LISP interpreter)

System status information

    date                    (print date and time)
    w                       (who is logged on)
    who                     (who is logged on)
    rwho                    (who is logged on all computers)
    finger meyer            (find out all about user "meyer")

Terminal information and status

    clear                   (clear terminal screen)
    stty echo               (turn echo back on)
    stty erase \X           (let the erase character be X, where X is usually
                             the backspace or delete key)
    stty                    (print out info about terminal)
    echo $term              (what kind of terminal does UNIX think I have?)

Interuser Communication

    mail                    (read incoming mail, if any)
    mail meyer              (send mail to user meyer) 
    mail meyer < somefile   (send mail to user meyer, taking it from somefile)
    mail meyer@canisius.edu (send mail to distant user via Internet)
    talk meyer              (interactive chat with meyer)
    write meyer             (send a quick message to meyer, press ^D when done)

On-line help

    man ls                  (read manual page for "ls" command)
    man -k set              (find out which manual page mentions keyword set)
    help                    (Canisius on-line help system)

REDIRECTION

    Many commands read from standard input (stdin) and write to standard output
    (stdout).  Normally, stdin is the keyboard of your terminal while stdout
    is the terminal screen.  Every data stream can be redirected to come from
    or go to a file instead, or another command.

    <         redirect standard input from a file
    >         redirect standard output to a file
    |         redirect either to/from another command

    sort myfile > newfile        Save sorted output into new file "newfile"
    a.out < datafile             Supposing a.out expects to read from stdin,
                                 it can come from a file instead.
    a.out < datafile > saved.output    Or you can redirect both

    who | wc -l                  Stdout of "who" goes into the wc command, which
                                 counts the lines so you can see how many folks
                                 are currently logged on

    cat chap*.dit | spell | less     Concatenate together all chapters of your
                                     latest book, run it all through the spell
                                     checker, and then page through the list of
                                     misspelled words