UNIX operating system Quick Reference

% alias lu 'ls -u'
    % lu
   
ALT-H presents a summary of special keys

cat  -  >   temp

CTRL d

The cat utility can also be used to join many files together into a single file. The command, 


        cat  temp  .profile  >   temp1

cp * /usr/tmp


would copy all the files in the current directory to the directory /usr/tmp.

head  -2  temp
would list the first 2 lines of the file temp on the console.

tail  -2  temp
This is used to view the last few lines of a file


lp temp
This command is used to obtain a hard copy printout of a file. ONLY type this command IF a
printer is attached to the computer system.


pr (print)

The print utility prints the file to stdout. The switches it accepts are 
        -ln     set page length in lines to n
        -wn     set line length in characters to n
        -n      number output lines
        -t      do not print page header or trailer
        -digit  number of columns to use
        +digit  start at page number

pr  -2  -n  temp

This prints the file temp to stdout, using two columns per line, numbering each line.


who -u

mesg (message) 

This command permits or denies messages invoked using write. The switches it uses are -y and -n

news 

The news command keeps the user informed of current events.


        grep 'change' temp

The grep command searches a file for a pattern. The following command 

searches the file temp in the current directory for the text string change. Using the * wildcard
specifies all files, and using the switch -n will display on which line the text string is found.


        time  ls  -la

This command times how long it takes to execute a given command. Type the command, 


The man command can also accept the following names as switches.

        ADM             System Administration
        C               Commands
        M               Miscellaneous
        F               File Formats
        HW              Hardware Dependent
        S               Subroutines and Libraries
        CP              Programming Commands
        DOS             DOS Subroutines and Libraries
        LOCAL           Local utilities for your system

An example command which calls up the reference section on 'Miscellaneous features' is (this may
not apply to all UNIX systems).

        man M

        mv temp temp2

The mv command is used for moving or renaming files. Type the command 

pwd             print current working directory

        cd              change directory

        mkdir           make a subdirectory

        rmdir           remove a subdirectory

Typing the set command will print out a list of all the current shell environments. This is a list of all
the variables and settings that the shell currently has.

The majority of these are loaded when you first log in. The first thing the shell does is execute the
file .profile in the users home directory!

Type the command, 

        set

shell variables 

The shell supports user and system variables. An example of system variables are,

        PS1             system prompt
        PS2             secondary line shell prompt
        HOME            home directory
        LOGNAME         login name

Variables are assigned values using the = sign.
PS1="Hi there : "
dir="ls -la"
$dir
sample="Hello world"

        echo $sample

A secondary copy of the shell is invoked by typing 
        sh
The secondary shell is terminated by typing exit.

Another feature of UNIX is running processes in the background. When a command is appended
with the & symbol, it is run in the background and the shell prompt immediately returns.

Each process in UNIX is identified by a PID (process identification number). When a
background process is started off, UNIX will print its PID number in square bracket
ls  -l  >   dirlist&

NOTE that the shell prompt immediately returns, and a number in brackets is printed. The &
character signals to the shell that the command is to run in the background.

        2868

sleep  200&

vi command

        k       up
        j       down
        h       left
        l       right

        a       appends to the last line of the file
        i       inserts at the current cursor position
        o       inserts one line down from the current cursor position
        O       inserts one line up from the current cursor position

        x       erase the character at the cursor
        r       replace the character at the cursor
        dd      delete the entire line where the cursor is

The u command undoes the previous command.

The U command undoes all the changes made on the current line.

You are strongly encouraged to save editing changes regularly. The command to write the editor
buffer is 


        :w
If you decide that you do want to over-write the existing file, but rather save the changes to a new
file, then follow the :w command with the name of the new file, 
        :w  newfile2

                ZZ      writes the buffer to disk into the original file, then returns to the shell
               :wq     same as ZZ
                :q!     quits the editor, abandons the buffer, and returns to the shell

       b       move the cursor to the beginning of the previous word
        e       move the cursor to the end of the next word
        0       move to the beginning of the line (zero)
        $       move to the end of the line

        ctrl-d          scroll down
        ctrl-u          scroll up

3000G           goto line 3000

To position the cursor at the last line in the file, type 
        G
To position the cursor at the beginning of the file, type 
        1G

         ctrl-g          display current line number

Searching
/ indicates a search forward
? To search backwards 
n will search forwards for the next occurrence.

dw command deleted the current word.
       


The dd, cc, and yy commands affect the entire line.
The temporary buffers are numbered 1 to 9,
the buffer number preceded by a double quote ( "np ).

There are 26 named buffers for use by the yank command. These buffers are named 'a' to 'z'.
       "ay}                    yank from cursor to end of paragraph into buffer a

thus the following command moves lines 1 to 3 to the end of the file. 
        1,3m$
 ps     list processes
 kill   kill a process
 &     run a process in the background

The system call is accessible as a set of 'C' functions, as the majority of UNIX is also written in
'C'. Typical system calls are, 


   _read    for reading from the disk unit
   _write   for writing to the disk unit
   _getch   read a character from a terminal
   _putch   write a character to the terminal
   _ioctl   control/set device parameters

Reserved IP Addresses
The following IP addresses are reserved for special purposes, and must NOT be assigned to
any host. 


 Network Addresses : The host portion is set to all zero's
    (129.47.0.0)

 Broadcast Address : The host portion is set to all one's
    (129.47.255.255)

 Loopback Addresses : 127.0.0.0 and 127.0.0.1