CDPATH=.:..:$HOME
PATH=.:./bin:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:\
/usr/local/bin:/usr/bin/X11
EDITOR=/usr/ucb/vi
ENV=$HOME/.kshrc
EXINIT='set ai nonumber showmatch wrapmargin=72 nowrapscan'
FCEDIT=/usr/ucb/vi
HISTSIZE=32
MAIL=/usr/spool/mail/$USER
PS1="! ${HOST%%.*}> "
SHELL=/usr/bin/ksh
export CDPATH EDITOR ENV EXINIT FCEDIT HISTSIZE HOST MAIL PATH PS1
export SHELL
biff y
tset -I
stty erase \^? kill \^U intr \^C
umask 0022
alias mail=/usr/ucb/mailx
OSTYPE=`uname`
|
CDPATH Directories searched by cd command.
EDITOR Sets default editor.
ENV Name of script that is executed at startup.
EXINIT Sets options for ex and vi editors.
FCEDIT Editor used by the fc command.
HISTSIZE Number of history commands available (must be set before ksh is started).
PATH Directories searched for any file (command) name. Most important shell variable.
PS1 Primary prompt string; default is $.
SHELL Name of shell environment.
export Pass the value of shell variables, giving global meaning to them.
tset Initializes terminals, setting the TERM variable.
biff y System notifies user of new mail.
stty erase Sets delete character for command line edits.
umask Sets (eliminates) file default access permissions.
alias Allows commands (and options) to be abbreviated.
set -o trackall |
Locate commands as they are defined.
| ${varname:-word} | If varname exists and isn't null, return its value; otherwise return word. |
|---|---|
| ${varname:=word} | If varname exists and isn't null, return its value; otherwise set it to word and then return its value. |
| ${varname:?message} | If varname exists and isn't null, return its value; otherwise print varname: followed by message, and abort the current command or script. |
| ${varname:+word} | If varname exists and isn't null, return word; otherwise return null. |
| ${varname#pattern} | If the pattern matches the beginning of the variable's value, delete the shortest part that matches and return the rest. |
| ${varname##pattern} | If the pattern matches the beginning of the variable's value, delete the longest part that matches and return the rest. |
| ${varname%pattern} | If the pattern matches the end of the variable's value, delete the shortest part that matches and return the rest. |
| ${varname%%pattern} | If the pattern matches the end of the variable's value, delete the longest part that matches and return the rest. |
[1] + Stopped spell termpaper [2] - Running find /usr -name main.exe -print & |
PID TT STAT TIME COMMAND 12360 p0 S 0:01 -ksh (ksh) 12372 p0 I 0:00 main 12425 p0 R 0:00 ps -x |
vi filename If there is no file, vi creates the file.
vi can be in one of the following three modes:
When vi is first loaded, it is in the command mode. This means that all keystrokes entered are interpreted as commands. To return to command mode from input mode, hit <ESCAPE>.
| Description | Command Code |
|---|---|
| Move one space to the right | Space, l, or right arrow |
| Move one space to the left | h, or left arrow |
| Move down one line | j, or down arrow |
| Move up one line | k , or up arrow |
| Move one word to the right | w, or W |
| Move one word to the left | b, or B |
| Move to beginning of line | 0 |
| Move to end of line | $ |
| Move to top of screen | H |
| Move to middle of screen | M |
| Move to bottom of screen | L |
| Save contents to file | :w |
| Quit file | :q |
| Quit vi, saving file only if changes were made | :x |
| Save file and quit vi | :wq |
| Save contents to file and quit vi | ZZ |
| Toggle between uppercase and lowercase | ~ |
| Delete back one character | X |
| Delete character under cursor | x |
| Delete line | dd |
| Delete word | dw |
See the vi notes for more commands and details.
The following commands leave vi in input mode. The table gives the position where the text is inserted.
| Description | Insert Text |
|---|---|
| Before cursor | i |
| At beginning of line | I |
| After cursor | a |
| At end of line | A |
| After current line | o |
| Before current line | O |
emacs filename If there is no file, emacs creates the file
Note that ``C-x" means ``hold down the Control key, and type the x key". ``M-x" means "type the ESC key, then type the x key". Alternatively, if your terminal has a Meta-key, then ``M-x" means "hold down the Meta key, and type the x key".
| Description | Command Code |
|---|---|
| Exit Emacs | C-x C-c |
| Suspend Emacs | C-z |
| Get help | C-h |
| Save a file | C-x C-s |
| Visit a new file | C-x C-v |
| Visit another buffer | C-x b |
| Abort a command | C-g |
| Down one screen-full | C-v |
| Up one screen-full | M-v |
| Forward one character | C-f |
| Forward one word | M-f |
| Back one character | C-b |
| Back one word | M-b |
| Down to next line | C-n |
| Up to previous line | C-p |
| Go to beginning of line | C-a |
| Go to end of line | C-e |
| Go to begining of file | M-< |
| Go to end of file | M-> |
| Set mark (begin region) | C-@ or C-SPACE |
| Go to mark | C-x C-x |
| Delete previous character (back) | DEL |
| Delete current character (forward) | C-d |
| Delete previous word (back) | M-DEL |
| Delete next work (forward) | M-d |
| Kill rest of line (send to kill buffer) | C-k |
| Delete region (from mark) (send to kill buffer) | C-w |
| Yank back kill buffer | C-y |
| Incremental search forward | C-s |
| Incremental search backward | C-r |
| Exit incremental search | ESC |
| Abort incremental search | C-g |
| Get rid of extra windows | C-x 1 |
| Split window in two | C-x 2 |
| Move cursor to other window | C-x o |
| Start a shell window | M-x shell |
| Run the compiler | M-x compile |
| Move to next compiler error | C-x ` |


![]() |
Devices in UNIX are represented as files:
e.g., /dev/console.
UNIX commands receive their input from the standard input (stdin) and send their output to the standard output (stdout), by default these files are the console or terminal. |
command name [args] > filename
ls -al > ls.out
progxcs1044 > px.out
progxcs1044 >> px.out
command name [args] < filename

progxcs1044 < px.inp > px.log
progxcs1044 > pt.out << !
first line of data
second line of data
. . .
last line of data
!
ls -al | more
ls -al > ls.out
more < ls.out
rm ls.out
% "How poorly would you rate the UNIX user interface? Unmatched ". % rm congressional-ethics rm: congressional-ethics nonexistent % ar m God ar: God does not exist. % [Where is Jimmy Hoffa? Missing ]. % ^How did the sex change^ operation go? Modifier failed. % make love Make: don't know how to make love. Stop. % got a light? No match. %man: why did you get a divorce? man: Too many arguments. % ^What is saccharine? Bad substitute. $ drink <bottle; opener bottle: cannot open opener: not found
Last modified: Mon Nov 3 09:41:41 EST 1997