Está en la página 1de 98

Advanced Unix Commands

Again this list is due to Per Kistler. Thanks Per !

ACCTCOM ::
See the commands of all users acctcom | tail -20
See the commands of a particual user acctcom -u <username> | tail -20
Show entries for a specific commandpattern acctcom -n <pattern> | tail -20
Show all entries for commands staring with "l" acctcom -n '^l' | tail -30
Swho the output in reverse order acctom -b | more
AGREP ::
Find words with possible misspellings (here 2) agrep -2 'macropperswan' <file>
AT ::
Execute a command once in the future at now + 5 days < scriptfile
AWK ::
Take first column of a file awk '{print $1}' <file>
Take first two colums inverted awk '{print $2,"\t",$1}' <file>
Print sum of first two colums awk '{print $1 + $2}' <file>
Find lines with "money" and print last column awk '/money/ {print $NF}' <file>
Find lines with "money" in second column awk '$2 ~ /money/ {print $0}' <file>
Find lines without "A" at end of 3-rd column awk '$3 !~ /A$/ {print $0}' <file>
BASH ::
Bourne again shell. Best interaktive shell right after
zsh
BC ::
Calculate sin(5) echo 's(5)' | bc -l
BG ::
Put last stopped job into the background bg
BREAK ::
Leave the inermost loop (while/until/for) break
CANCEL ::
Stop a print job allready started cancel <jobid> ( as found with lpstat -o)
CASE in ESAC ::
Selective structure in sh/bash/ksh
CC ::
Compile a file.c cc -o <outfile> <infile>
CHGRP ::
Change group of a file chgrp <newgroupname> <file>
CHOWN ::
Change owner of a file chown <newowner> <file>
CMP ::
Act on the difference of two files cmp <file1> <file2> || <command>
COL ::
man <command> | col -b |
Printing the man pages without thousand "^H"
<printcommand>
CRONTAB ::
See your crontab file crontab -l
Edit your crontab file crontab -e
Every monday on 05:10 do /home/fred/foo.ksh 10 5 * * 1 /home/fred/foo.ksh
CRYPT ::
Encrypt a file with a password crypt password < infile > cryptfile
Decrypt the above file crypt password < cryptfile > cleanfile
CSH ::
Oldest Berkley shell
CUT ::
Get the hostname field from the last output last | cut -c11-40
DATE ::
Set the date (root only) date <mmddhhmm>
Special format of date (e.g. month only) date +%m
DF ::
See the used space of the disks in kB df -k
DIRCMP ::
Compare two directories dircmp <dir1> <dir2>
DTKSH ::
dtksh is a ksh93 with X11 graphics dtksh
DU ::
du = diskusage du -ks
ED ::
Commandline editor. Only used if all else fails ed <file>
EGREP ::
Grep with "or" egrep '(A|B)' <file>
Exclude a and B egrep -v '(A|B)' <file>
EX ::
ex -s file <<EOF
Edit a file from within a shell script g/money/s//cash/
EOF
Edit a file with a script ex -s file < scriptfile
EXPR ::
Calculate modulus expr 10 % 7
Check for string in variable expr $var : 'string'
Show first group of digits in string expr $var : '[^0-9]*\([a-z]*\)'
FG ::
Put the last stopped job into the foreground fg
FGREP ::
Find a string which is not a pattern fgrep '*,/.()' <file>
FILE ::
See the file type (e.g. ascii) file <file>
FIND ::
Find a file in the whole computer find / -type f -name <file> -print
Find a file pattern find . -type f -name "*<foo>*" -print
find / -type f -name core -exec /bin/rm -f
Delete all cores in the system
{} \;
Find all files with a word in them find . -type f -exec grep -l <word> {} \;
Find files modified longer than a month ago find . -type f -ctime +30 -print
find . -name "*.c" -print | xargs -i cp {}
Use found files more then once with xargs
{}.bak
Don't search in nfs mounted filesystems find . -local ...
Follow the links while searching find . -follow ...
Look for files larger than 1 megabyte find /path -size 1000000c -print
Run find but discard the "permission denied"'s find ... 2>/dev/null ( in sh/bash/ksh only)
find / -type d -print | egrep '.*/(catman|
Find all manualpage directories
man)$'
Find all directories with write permissions find / -type d -perm -002 -print
GAWK ::
The gnu version of nawk
GREP ::
Find patterns in lines of files or stdin grep '[a-z][0-9]' <file>
Find lines without pattern grep -v '^From' <file>
Find files which contain a pattern grep -l '^[cC]' *.f
Count lines with pattern grep -c '[Ss]uccess' <file>
Search while ignoreing case grep -i 'lAbEgF' <file>
Print a line number in front of the line grep -n 'mo.*y' <file>
HINV ::
Get infos about your host on silicon graphics hinv -v
IF then else ENDIF ::
Branching structure in csh/tcsh
IF then else FI ::
Branching structure in sh/bash/ksh if [[ condition ]];then commands;fi
KSH ::
Korn shell. (ksh88)
KSH93 ::
ksh93 with real number arithmetics ksh93/ksh...depends on the system
LINE ::
Reprint lines until eof (sh/bash/ksh) while line;do :;done
LN ::
Make a hard link b to file A ln a B
Make a symbolik link b to file A ln -s a B
Romove link B rm B
LP ::
Print file on default printer lp <file>
Print file on specific printer lp -d <destination> <file>
LPSTAT ::
Show all printers lpstat -a
Check the printer queue lpstat -o
Show defoult printer destination lpstat -d
Show printer status lpstat -p
Show sceduler status lpstat -r
MAKE ::
Make the first target of a makefile make
Make a specific target of a makefile make <target>
Make according to another file than makefile make -f <mymakefile>
Just show what would be done but don't make -n <target>
MKDIR ::
Make a directory with subdirectories at once mkdir -p <path>/<path>/<path>
MOUNT ::
See what is mounted mount
See what is mounted, but formated mount -p
Mount a cdrom to /cdrom mount /dev/cdrom /cdrom
Mount a diskpartition to /usr mount /dev/dsk/c0t3d0s5 /usr
NAWK ::
Enhanced version af awk
NL ::
Number text lines from a file nl -bt -nln <file>
NOHUP ::
Start a job imune to logouts nohup <command> &
OSVIEW ::
View system activity on SGI osview
PACK ::
An old form of compress. Use gzip instead. pack <file>
PASSWD ::
Change your password passwd
Delete password of a user (as root) passwd -d <username>
Change password of a user (as root) passwd <username>
PASTE ::
Put single col files into one file with as many cols paste <file1> <file2> > <newfile>
PERL ::
Programming language which can also be used from
the commandline or from ksh scripts.
PR ::
Format an ascii file for printing (76 lines) pr -l76 -h"title" <filename>
rcp <comp1>:/<path>/<file>
Copy a file from one computer to another
<comp2>:/<path>/
REGCMP ::
Compile a regexp from a file regcmp <file>
Entry in the file above (example) varname "^[a-z].*[0-9.*$"
RESET ::
Reset the terminal after having messed it up reset
RPCINFO ::
Get portinfo from <host> rpcinfo -p <host>
RSH ::
Execute a command on a remote computer rsh <host> <comand>
RUSER ::
See who is logged in in the local network rusers
RWHO ::
Like rusers, but mostly doesn't work
SCRIPT ::
This logges all which passes the screen script <logfile>
SED ::
Substitute a string in a file sed -e 's/fred/john/g' <file>
Substitute a pattern in a file sed -e 's/[0-9]+/number/g' <file>
sed -e 's!X!<font
Change all "X" to red in a html file
color="#FF0000">X</font>!g;
Rename files with suffix .suf1 to files with suffix ls -1 | grep '\.suf1$' | sed -e 's/\
.suf2 (.*\.\)suf1/mv & \1suf2/' | sh
Change a to b but only on lines with C sed -e '/C/s/A/B/' <infile> ><outfile>
Delete all lines which contain "you owe me" sed -e '/you owe me/d' <infile> > <outfile>
Have many editing commands in a file sed -f <commandfile> <infile> > <outfile>
SH ::
Shell. The oldest AT&T shell, which is standard for
universal shell scripts. Ksh is it's successor.
SHUTDOWN ::
Stop the system shutdown -h now
SLEEP ::
Tell ashell script to pause for 10 seconds sleep 10
SORT ::
Sort lines of a file alphabetically sort <file>
Sort lines of a file numerically sort -n <file>
Sort and reverse the order sort -r <file>
Sort and take only one of equal lines sort -u <file>
Show the used user ID's from /etc/passwd sort +2n -t: /etc/passwd | cut -d: -f3
SPELL ::
Check for misspelled words in a file spell <file>
Check, but ignore words from okfile spell +<okfile> <file>
SPLIT ::
Split a big file for putting on floppy split -b1m <file>
Put splitters together if their name starts with x cat x* > <newfile>
STRINGS ::
Read ascii strings from a binary file strings <file>
STTY ::
Show the terminal settings stty -a
Change the deletions chatachter to "^H" stty erase "^H"
Do no more show what is typed in scripts stty -echo
Show the typeing again stty echo
SU ::
Become root with own environment su
Become root with root environment su -
As root become another user su <username>
TAIL ::
Report certain lines from a growing file tail -f <file> | grep <pattern>
TAR ::
Pack together a whole directory tar cvf <outfile>.tar <dir>
Unpack a tar file tar xvf <file>.tar
Unpack and untar a file with normal tar gzip -dc <file>.tar.gz | tar xvf -
Unpack and untar a file with gnutar tar xzvf <file>tar.gz
Set the tape variable in the .cshrc for tar tape=/dev/rmt/0mbn
Put a dir onto the tape tar cv <dir>
Retrieve the dir from the tape tar xv
Retrieve only a single file from the tape tar xv <file>
Get table of contents from tape tar t
(cd fromdir && tar -cBf - . ) | ( cd todir
Copy a directory with links and propper permissions
&& tar -xBf - )
TCSH ::
Good interaktive shell from Berkly. Only second to
bash.
TEE ::
Put output on screen and append to file who | tee -a > <file>
TEST ::
Check for a file test -a <file>
Check for beeing root test -O /usr/bin/su
Check for astrin beeing non null test -n "$foo"
Compare two strings numerically test $var1 -gt $var2
In a ksh script one uses "test" indirectly if [[ -a <file> ]];then ...;fi
TIME ::
See how much time a command needs time <command>
TOUCH ::
Protect against the the crontab find /myscratch -exec touch {} \;
TR ::
Replace a with x, b with y and c with z tr '[a-c]' '[x-z]' < infile > outfile
TRAP ::
Catch "^C" etc. and execute a subroutine trap "mysub;exit" 0 1 2 15
TRUE ::
Make a non extisting command to return 0 ln -s /usr/bin/true ranlib
TRUSS ::
See what system calls a command uses truss <command> > /dev/null
TYPSET ::
Show the functions which are active typset
TTY ::
See the device for your terminal tty
ULIMIT ::
Show the max file size you can write ulimit
UMASK ::
Show your umask for new files umask
Set a save umask umask 077
UNIQ ::
Find a line of each equal ones an say how many sort <file> | uniq -c
Find uniq lines sort <file> | uniq -u
UPTIME ::
Show how long the computer is running uptime
UUENCODE ::
uuencode decodedname namenow >
Encode a file for mailing
codedname
UUDECODE ::
Decode a uuencoded file uudecode <file>
WAIT ::
Wait for a background job to terminate wait $jobid
VI ::
The main unix editor vi <file>
WC ::
Count lines in a file wc -l <file>
XARGS ::
Execute a command for each line from pipe <command> | xargs -i grep 'pattern' {}
XON ::
Get an xterm from another computer xon <host>
Get anything from another computer xon <host> <X-client>
More Advanced Unix Commands
 
More information on almost any of the commands that
follow can be found in the on-line manual pages. Type
   
``man command-name'' at the command line to look at the
manual page for the command ``command-name''.
Files Processes 

 Viewing and Printing,   Run two or more jobs at once : &, bg, fg
 TeX and LaTeX files : Dvi  
 
 
 
 Run a big job with low priority : nice
 Graphically display processes running :
 Compressing / Uncompressing: compress, gr_top
uncompress, gtar, tar, gzip, gunzip  Suspend a job : [CTRL]-z
 

 Kill a job : [CTRL]-c , kill


Redirection  

 Take output from one job and make it the  


input to another job: |, < , >
 copy files while filtering with given script :
sed 
 search file for pattern : awk, grep

Colors

 editing colormaps : bitmap


 

 view a color based on decimal values


(on SGI's) : cedit
 

 Text Filters / Pattern matching

|
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.
-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.
-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 EMBA 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
room 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.
-Pembalaz ). 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.
badb
BADB ( Business ADministration Database ) is used to access the Stock Exchange
information supplied on the CRSP and Compustat tapes. Type ``badb'' at the command
line, and choose the data base that you wish to enter. It is interactive, and there is on-line
help.
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 (Newton, Griffin, Sadye,
ect ...)
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.
djns
Dow Jones News Retrieval Service. This service can give you up-to-the-minute news,
current and historical stock quotes, the MCI Mail service, Official Airline Guide flight
and fare information, as well as detailed corporate and industry data. Also available in
this unique service are a wide variety of general interest databases, including sports and
weather reports, a computerized shopping service, movie reviews, a lexicon of
investment terminology and an encyclopedia.
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. 
gr_top
Graphically displays processes ordered by %CPU usage.
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.
interleaf
A WYSIWYG ( What You See Is What You Get ) editor and desktop files organizer
available on the Sun machines. For more information look in the printed manual pages.
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 an EMBA 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''.
wp51
WordPerfect 5.1. Available on Sun's. For the ASCII version, you must first unset your
``DISPLAY'' environment variable ( ``unsetenv DISPLAY'' ), then type ``wp51''. For the
X-windows version of wp51 you must first set your ``DISPLAY'' environment variable
( ``setenv DISPLAY dname:0'', where dname is the name of the display that you are
using ), and then you must tell it where to find the appropriate fonts by typing ``xset
fp+ /usr/local/lib/X11/fonts/wp'' on the console of the machine that you are working on,
then simply type ``wp51'' at the command line in one of your Sun windows ( griffin,
newton, sadye ).
xarchie
X-window interface for Archie servers. Archie servers provide information about files
available for ftp anywhere on the Internet. ( i.e., it helps you figure out where you can ftp
a particular file from ). Say you want to find out where you can ftp the gdb debugger
from - you'd type ``gdb'' in for the ``Search Term:'', and then press return. Xarchie will
then connect to one of the archie servers ( which one can be controlled though the
``settings'' menu ), and look for any file that it know about that contains the string ``gdb''.
It will report the ftp servers, the directory, and the file found on your screen. You can
then use ftp to get the file if you want it.

Basic Unix Commands


More information on almost any of the commands that
follow can be found in the on-line manual pages. Type
   
``man command-name'' at the command line to look at the
manual page for the command ``command-name''.
 
 

Files Environment

 Display files in a directory :ls  Keep getting "Can't open display: :


  0" :setenv 
 Display current environment variables:
  env
   
 
   
   
 
 Copying files : cp
 Delete file(s) : rm
 What kind of file is this ? : file Networking
 Where is this file ? : find , which
   Check your mail or mail someone : mail ,
pine 
   Information on a person : finger 
   Information on people logged-on rwho 
   Info on Printers : printers
   
 
 
 Compile a file : cc, cc++, g++, gcc, CC   
 Debug a program : gdb  
 Whats in this file ? :more, less, cat  
   

   Printing a file : lpr


   Check the print queue :lpq
   
 
   
 
 Whats different with these two files ?diff,  
cmp  
   

   Cancel print jobs :lprm


   
 
 
 

 View a file in PostScript (.ps file): gv 


 Edit a file : emacs, vi, pico  
   
 
   
   
 
   Transfer files over Network :ftp, kermit
   

 Change permission : chmod  


   
 
   
   
 
   HOW DO I QUIT !? : logout
   

 Finding man page : man -k  


   
 
   
   
 
   Information on Servers : rupall
   
 
 Moving files : mv  
 Did I spell that right?: spell, ispell  
   
   
 
 
 
 
Directories Processes

 Where am I now ?? : pwd  What program is running now? jobs, ps


 Moving around : cd , ln  
 Create a directory : mkdir
 Delete a directory : rmdir
 Change permissions to a directory :  
chmod  
   

 
  Passwords
 
   CHANGE YOUR PASSWORD ! passwd
   

 How much disk space do I have left ?  


quota -v  
   

   
 
 

 
c++ {filename}
A compiler for the C++ programming language. Command line parameters are similar to
the ``cc'' compiler's. A typical invocation might be ``c++ -g file.cpp -o executablename
-llib''. 

cat {filename}
Prints out ( to the screen ) the contents of the named file. Can also be used to concatenate
files. Say you want file1 and file2 to be all together in one file named file3. If file1 is
first, then ``cat file1 file2 > file3'' will produce the correct file3. 

cc
A compiler for the ``C'' programming language. ``cc'' is ANSI compatible on the SGI,
IBM, and newer Sun machines. You might try also try ``gcc'', GNU CC, which is also
available on the SGI, SUN, and IBM machines. A typical invocation might be ``cc -g
file.c -o executablename -llib''. 

cd {dirname}
Change current directory. Without a ``dirname'', it will return you to your home directory.
Otherwise, it takes you to the directory named. ``cd /'' will take you to the root directory. 

chmod {options}
Changes the permission modes of a file. If you type ``ls -l'' in a directory, you might get
something like this:
    drwx------ 3 ertle 512 Jul 16 13:38 LaTeX/
    drwxr-xr-- 2 ertle 512 Jun22 12:26 X/
    drwxr-xr-x 3 ertle 512 Jul 13 16:29 Xroff/
    -rw-r--r-- 1 ertle 373 Oct 3 1992 o.me
    -rw-r--r-- 1 ertle 747 Nov 21 1992 profile
    -rwxr-xr-x 1 ertle 244 Jul 16 23:44 zap*
The first part of the line tells you the file's permissions. For example, the ``X'' file
permissions start with a ``d'' which tells that it is a directory. The next three characters,
``rwx'' show that the owner has read, write, and execute permissions on this file. The next
three characters, ``r-x'' shows that people in the same group have read and execute
permission on the file. Finally, the last three characters ``r-'' show that everyone else only
has read permission on that file ( To be able to enter a directory, you need read AND
execute permission ). Users can use ``chmod'' to change these permissions. If the user
didn't want anybody else to be able to enter the ``X'' directory, they would change the
permissions to look like those of the LaTeX directory, like this : ``chmod og-rx X'' - this
means remove the read (``r'' ) and execute (``x'') permissions from the group (``g'') and
others (``o'').

cmp {file1} {file2}


Compares the contents of two files from eachother. Reports the first different character
found, and the line nummber. 

cp {filename(s)}{path}
Copies files from one directory/filename to another. ``cp f1 f2'' makes a file ``f2''
identical to ``f1''. ``cp *.c src/'' copies all files that end in ``.c'' into the ``src''
subdirectory. 

ctags
Creates a tags file for use with ex and vi. A tags file gives the location of functions and
type definitions in a group of files. ex and vi use entries in the tags file to locate and
display a definition. 

date
Shows current date and time. 

dbx {executable}
Source level debugger. In order to use this, you must use the ``-g'' option when compiling
your source code. Allows you to set break-points, single step through the program, etc. 

diff {file1} {file2}


Displays all the differences between two files or directories to the screen. 

elm {login-name}
Runs a screen oriented mail reader. With a ``login-name'', starts elm to send mail to
``login-name''. Otherwise, it starts elm for an interactive session. 

emacs {filename}
Runs the most recent version of the text editor named EMACS ( produced by the GNU
project ). If filename is present, it will start editing that file. Type ``<CTRL>-x <CTRL>-
h t'' to start a tutorial. ``<CTRL>-x <CTRL>-c'' will exit from emacs. 
env
Prints out the values for all the current environment variables. Some typical environment
variables are ``DISPLAY'', ``EDITOR'', and ``PRINTER''. 

xemacs {filename}
An X version of emacs. 

file filename(s)
Looks at ``filename(s)'' and tells what type of files they are. This is useful in checking a
file to be sure that it is text before you ``cat'' it out ( using ``cat'' on binary files can be a
bummer ). Example:
    ertle@newton (55)> file *
    useful.dvi: data
    useful.hlp: English text
    useful.tex: ascii text
    xwin.dvi: data
    xwin.tex: English text
    ertle@newton (56)>

find
Searches the named directory and it's sub-directories for files. Most frequently called like
this:
    find ./ -name ``t*'' -print
Which searches the current directory ( and all of its sub-directories ) for any files that
begin with the letter 't' and then prints them out. If you are looking for a specific
filename, then replace ``t*'' with ``filename'', and ``find'' will print out all incidences of
this file.

finger {login-name}
Without a ``login-name'', finger shows who is currently logged on the system, with
limited information about them. With a ``login-name'' you get more detailed info, along
with anything that is in that person's ``.plan'' file. 

ftp {address}
File Transfer Program. ``ftp'' transfers files to and from a remote network site. There are
many ftp-sites that will let you log in as ``anonymous'' and get software/data/documents
from them for free. After connecting, ``ls'' will print out the files in the current directory,
and ``get filename'' will transfer the named file into your local directory. Be sure to type
``binary'' before transferring non-ascii ( executable, compressed, archived, etc ) files. To
exit ``ftp'' type ``bye''. See also ``xarchie''. 

g++
GNU project's compiler for the C++ language. Parameters are similar to those of ``cc''. A
typical invocation might be ``g++ -g filename.cpp -o executablename -llib''. More
information available under ``libg++'' in the emacs information browser ( M-x info while
in emacs ). 

gcc
GNU project's compiler for the C language. Command line parameters are mostly similar
to those of ``cc''. More information available under ``gcc'' in the emacs information
browser ( M-x info while in emacs ). 

gdb
GNU project's source level debugger. Must use the ``-g'' command line option when
compiling to use this debugger. This debugger is superior to dbx when called from inside
emacs ( M-x gdb ) because it gives you a full-screen look at the source code instead of
line by line, and allows you to move around and make break-points in the source file.
More information available under ``gdb'' in the emacs information browser ( M-x info
while in emacs ). 

ghostview {filename.ps}
X PostScript previewer. PostScript is a text processing and graphics language, and
ghostview is handy for looking at the resulting page or picture before you send it to the
printer. 

gossip
Anonymous local message center. 

ispell filename
Interactively checks the spelling of the named file, giving logical alternatives to the
misspelled words. Type ``?'' to get help. ``ispell'' can be accessed from the command line,
and also through emacs with M-x ispell-buffer. 

jobs
Shows backgrounded (<CTRL>-z'ed) processes with pid #'s. 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

jove {filename}
Johnathan's Own Version of Emacs. Another emacs editor. Jove doesn't have as many
features as GNU's emacs, but some people prefer it. <CTRL>-x <CTRL>-c to exit. 

less filename
Displays file with minimal space.
kermit
File transfer program. Allows you to transfer files between computers - your PC at home
to/from the computers at school, for instance. For more information, look in the online
manual pages. 

ln -s {source} {dest}
Creates a symbolic link from {source} to {dest}. {Source} can be a directory or a file.
Allows you to move around with ease instead of using long and complicated path names. 
logout
Exits and disconnects your network connection. 

lpq {-Pprintername}
Reports all print jobs in the queue for the named printer. If no printer is named with
-Pprintername, but the ``PRINTER'' environment variable is set to a printer name, ``lpq''
will report on that printer. 

lpr {-Pprintername}filename
Queues file ``filename'' to be printed on ``printer''. If no printer is specified with
-Pprintername, but the ``PRINTER'' environment variable is set, then the job will be
queued on that printer. 

lprm {-Pprinter}{job-number}
Lprm removes a job or jobs from a printer's spooling queue ( i.e. it stops it from being
printed or printing out the rest of the way ). Typically, you'd get the job number from the
``lpq'' command, and then use lprm to stop that job. 

ls {directory}
Shows directory listing. If no ``directory'' is specified, ``ls'' prints the names of the files in
the current directory.
ls -l {directory}
Shows long directory listing. If you type ``ls -l'' in a directory, you might get something
like this:
    drwx------ 3 ertle 512 Jul 16 13:38 LaTeX/
    drwxr-xr-- 2 ertle 512 Jun 22 12:26 X/
    drwxr-xr-x 3 ertle 512 Jul 13 16:29 Xroff/
    -rw-r--r-- 1 ertle 373 Oct 3 1992 o.me
    -rw-r--r-- 1 ertle 747 Nov 21 1992 profile
    -rwxr-xr-x 1 ertle 244 Jul 16 23:44 zap*
The first part of the line tells you the file's permissions. For example, the ``X'' file
permissions start with a ``d'' which tells that it is a directory. The next three characters,
``rwx'' show that the owner has read, write, and execute permissions on this file. The next
three characters, ``r-x'' shows that people in the same group have read and execute
permission on the file. Finally, the last three characters ``r-'' show that everyone else only
has read permission on that file ( To be able to enter a directory, you need read AND
execute permission )

mail {login-name}
Read or send mail messages. If no ``login-name'' is specified, ``mail'' checks to see if you
have any mail in your mail box. With a ``login-name'', ``mail'' will let you type in a
message to send to that person. For more advanced mail processing, you might try ``elm''
or ``pine'' at the command line, or ``M-x mail'' in emacs. 

mkdir dirname
Makes a sub-directory named ``dirname'' in the current directory. 
man -k pattern
Shows all manual entries which have ``pattern'' in their description. 

man {section}name
Shows the full manual page entry for ``name''. Without a section number, ``man'' may
give you any or all man pages for that ``name''. For example, ``man write'' will give you
the manual pages for the write command, and ``man 2 write'' will give you the system
call for ``write'' ( usually from the C or Pascal programming language ). 

more filename
Displays the contents of a file with pagebreaks. Usefull to use 'file' first so you don't
display garbage.
mv filename path
Moves ``filename'' to ``path''. This might consist of a simple renaming of the file, ``mv
file1 file2'', moving the file to a new directory, ``mv file1 /tmp/'', or both ``mv file1
/tmp/file2''. 

pico
   Very basic text editor, same interface as pine
pine
Full featured graphical mail reader/sender. 'pine' will read your mail, 'pine username' will
prepare a message to 'username'. 

printers
Shows available printers and current status. 

ps {options}
``ps'' reports that status of some or all of the processes currently running on the system.
With no command line parameters, ``ps'' only shows processes that belong to you and
that are attached to a controlling terminal. 

pwd
Shows current working directory path. 

quota -v
Shows current disk usage and limits. 

rm filename(s)
Removes files. Careful with this one - it is irreversible. It is usually aliased ( in a user's
.cshrc file ) to ``rm -i'' which insures that ``rm'' asks you if you are sure that you want to
remove the named file. 

rmdir dirname
Removes the directory ``dirname''. 

rupall
Reports that status of local compute servers. 

rwho
Similar to ``who'', but shows who is logged onto all emba machines as well as the local
machine. Without ``-a'', rwho shows all the people with under one hour idle time. With
the ``-a'', rwho shows everybody that is logged on. 

 
setenv
Sets environment variables. Most frequently used to tell X which display you are on with
``setenv DISPLAY displayname:0''. Also used in .cshrc file to set ``EDITOR'' and
``PRINTER'' environment variables. This tells programs which editor you prefer, and
which printer you want your output to be printed on. 

spell {filename}
Checks the spelling of the words in the standard input by default, checks words in
``filename'' if a name is supplied on the command line. If a word is misspelled it is
printed to stdout ( usually the screen ). 

trn
Threaded, full page network news reader. Quicker than vn. 

tin
Threaded, full page network news reader. Easier to use than trn. 

vi {filename}
Runs the screen oriented text editor named ``vi''. If a filename is specified, you will be
editing that file. Type ``[ESC]:q!'' to exit without making any changes. 

vn
Runs the screen oriented network news program. Old and slow - maybe try ``trn'' or
``tin''. 

whereis {command}
Reports the directory in which the {command} binary redides. 

which {command}
Reports the directory from which the {command} would be run if it was given as a
command line argument. 

who
Shows who is currently logged on the system. The ``w'' command does the same thing,
but gives slightly different info. 
write loginname
Send a message to another user. Each line will be sent to the other person as you hit the
carriage-return. Press <CTRL>-D to end the message. Write won't work if the other user
has typed ``mesg n''. 

xcalc
X scientific calculator. 

xcalendar
X calendar. Interactive calendar program with a notebook capability. 

xclock
X clock. 

xforecast
X interface to national weather forecast. 

xgdb
X interface to the gdb debugger. 

xman
X interface to the online manual pages. 

passwd
Interactively changes your password. 

ls ................. show directory, in alphabetical order


logout ............. logs off system
mkdir .............. make a directory
rmdir .............. remove directory (rm -r to delete folders with files)
rm ................. remove files
cd ................. change current directory
man (command) ...... shows help on a specific command
talk (user) ........ pages user for chat - (user) is a email address
write (user) ....... write a user on the local system (control-c to end)

pico (filename) .... easy to use text editor to edit files


pine ............... easy to use mailer
more (file) ........ views a file, pausing every screenful

sz ................. send a file (to you) using zmodem


rz ................. recieve a file (to the unix system) using zmodem

telnet (host) ...... connect to another Internet site


ftp (host) ......... connects to a FTP site
archie (filename) .. search the Archie database for a file on a FTP site
irc ................ connect to Internet Relay Chat
lynx ............... a textual World Wide Web browser
gopher ............. a Gopher database browser
tin, trn ........... read Usenet newsgroups
passwd ............. change your password
chfn ............... change your "Real Name" as seen on finger
chsh ............... change the shell you log into

grep ............... search for a string in a file


tail ............... show the last few lines of a file
who ................ shows who is logged into the local system
w .................. shows who is logged on and what they're doing
finger (emailaddr).. shows more information about a user
df ................. shows disk space available on the system
du ................. shows how much disk space is being used up by folders
chmod .............. changes permissions on a file
bc ................. a simple calculator

make ............... compiles source code


gcc (file.c) ....... compiles C source into a file named 'a.out'

gzip ............... best compression for UNIX files


zip ................ zip for IBM files
tar ................ combines multiple files into one or vice-versa
lharc, lzh, lha .... un-arc'ers, may not be on your system

dos2unix (file) (new) - strips CR's out of dos text files


unix2dos (file) (new) - adds CR's to unix text files

UNIX Commands Quick List


UNIX is EASY! There are only ~45 commands that you have to learn to use a UNIX
workstation. Before reading this list of unix commands, you may want to review the
Abbreviations Used in this Guide.

 COMMAND LISTS
o Environmental Commands

o File Manipulation

o Directory Manipulation

o Process Control

 System Security
 Typing Shortcuts
 Abbreviations Used in this Guide

Environmental Commands

logout or exit end terminal session


passwd change password
date print date & time
whoami or who
list current user in that window
am i
who list all users logged onto the workstation
man command1 print on-line UNIX manual page for command1
start file transfer protocol to transfer file between local and remote
ftp hostname
workstations. Remote workstation is named hostname
telnet hostname log onto remote workstation named hostname
df -k print list of disks and current capacity (in kilobytes)
setenv list environmental variables
which command list location of executable command

File Manipulation

list contents of current directory. Examples:


ls file.1 lists presence of file.1
ls
ls -l lists presence of file.1 with expanded information
ls -a lists contents of current directory, including files that start with "."
jot file.1 opens jot editor; reads file.1 into jot for editing
cat file.1 show contents of file.1 on screen
more file.1 show contents of file.1 on screen, but doesn't scroll past top of screen
head file.1 show first 20 lines of file.1 on screen
tail file.1 show last 20 lines of file.1 on screen
diff file.1 file.2 shows differences between file.1 and file.2
counts lines, words, and characters in file file.1. Variations:
wc -l counts lines in file file.1
wc
wc -w counts words in file file.1
wc -m counts characters in file file.1
copies file.1 to file.2. If file.2 exists, it is overwritten. Original file.1 is not
cp file.1 file.2
removed
moves file.1 to file.2. If file.2 exists, it is overwritten. Original file.1 is
mv file.1 file.2
removed
rm file.1 remove file.1. No utilities exist to retrieve it
grep PATTERN
print all lines that contain PATTERN in file.1
file.1
lpr file.1 print file.1 on default laser printer
Show list of available printers and questions to direct your printing of a file
lpr
to a particular printer
print size (in kilobytes) of current directory ("."). Variations:
du -sk du -sk * prints sizes (in kilobytes) of all files and sub-directories
du -sk file.1 prints size (in kilobytes) of file.1
reduce the size of file.1 and replace it with a file named file.1.Z. This
compress file.1
compressed file is NOT a (readable) ASCII file.
uncompress file.1.Z restore the compressed file file.1.Z
find the loation of file.1 in the directory and sub-directories. Variations:
find . -name file.1
find . -name "*pattern" -print finds all files that end with pattern.
-print
find . -name file.1 -exec rm '{}' ';' removes all files named file.1.
grep pattern file.1 print only the lines of file.1 that contain pattern
displays contents of file.1 sorted alphabetically. Variations:
sort file.1 sort -n file.1 displays contents of file.1 sorted numerically
sort -r file.1 displays contents of file.1 sorted alphabetically in reverse order.

Directory Manipulation

pwd show the directory that you are in (present working directory)
cd dir.1 change directory to dir.1
mkdir dir.1 make new directory dir.1

rmdir dir.1 remove EMPTY directory dir.1


rm -r dir.1 remove directory dir.2 AND its contents
cp -r dir.1 dir.2 copy dir.1 (and its contents) to dir.2
mv file.1 dir.1 move file.1 to dir.1
show contents of current directory. Variations:
ls ls dir.1 shows contents of dir.1
ls -d dir.1 shows PRESENCE of dir.1
du -sk dir.1 show sum of size (in kilobytes) of dir.1 and its contents
tar -cvf dir.1.tar dir.1 store an image of dir.1 and it's contents in file file.1

Process Control

command1& execute command1 in background


ps -ef print expanded list of all processes
kill pid1 remove process pid1
<control-c> interrupt current process
<control-z> suspend current process
jobs display background and suspended processes
kill %1 remove suspended process #1
top display the current, most computer-intensive commands
osview display the operating system statitistics

System Security
The following mechanism is the ONLY guaranteed method of protecting your work.

Each file and directory is owned by a user, and each user belongs to a group. By default, users
own their home directory (the current directory when the user logs in) and the contents of the
home directory. Most other files and directories are owned by "root" and other special users. The
user assigns a type of privilege to each file and directory owned by the user. By default, the
privilege is rwxr-xr-x.

The first three characters of rwxr-xr-x indicate that the owner can read, write, and execute the
file (or directory). The middle three characters indicate that all other users in the same group as
the owner can read and execute the file (or directory), but cannot write onto the file (or
directory), as indicated by the middle "-" character. The last three characters indicate that
everyone else on the system can read and execute the file (or directory), but cannot write onto
the file (or directory), as indicated by the last "-" character.

To change the owner's permissions of a file (or directory), the owner can type:

chown u+r file.1 chown u+w file.1 chown u+x file.1


chown u-r file.1 chown u-w file.1 chown u-x file.1
To change the group's permissions of a file (or directory), the owner can type:
chown g+r file.1 chown g+w file.1 chown g+x file.1
chown g-r file.1 chown g-w file.1 chown g-x file.1
To change the permissions of a file (or directory) for everyone else, the owner can type:
chown o+r file.1 chown o+w file.1 chown o+x file.1
chown o-r file.1 chown o-w file.1 chown o-x file.1

Typing Shortcuts
A. file* specifies all files and sub-directories that start with "file" and have 0 or more extra
characters. *file* specifies all files and sub-directories that contain the string "file" anywhere in
their name. fi*le specifies all files and sub-directories that start with "fi" and end with "le", with
0 or more extra characters.

B. file? specifies all files and sub-directories that start with "file" and have one extra character.
C. The current directory can be specified as ".", and the parent directory of the current directory
can be specified as "..". For example, if the current directory is /usr/people/mpagel, I can copy
the file /usr/people/huffman/Crambin.pdb to /usr/people/mpagel/pdb/ by typing:

cp ../huffman/Crambin.pdb ./pdb/

D. Text on the screen can be highlighted by sweeping the mouse cursor over the text while
pressing and holding the left mouse button. This text can be inserted at the command line by
clicking the center mouse button, regardless of the mouse cursor position (as long as the mouse
cursor remains in the window).

E. If you type the first part of the name of a file or sub-directory in the current directory and then
hit the <Esc> escape key, the workstation will complete the name for you. For example, if the
current directory contains the files template.001 and temporary.stuff, then I can type:
more templ<Esc>
and the workstation will complete the name template.001. Note that if I type:
more temp<Esc>
then the workstation will NOT complete the file name, since I have not specified enough
characters to unambiguously specify template.001 instead of temporary.stuff.

F. history shows list of last 100 commands


!! repeats last command
!32 repeats command #32 in the history list
!mor repeats last command starting with "mor"

G. If I type mv file.1 dir.1 to move file.1 to dir.1, then I can move file.2 to dir.1 by typing ^1^2,
which does the following command: mv file.2 dir.1. Note that the only the first "1" (in file.1)
changes, and the "1" in dir.1 does NOT change.

H. Many commands have 'modifiers'. For example, ls -l has a modifier "-l" which specifies that
the LONG listing of the directory contents should be printed. Many modifiers can be combined
in any order in one command. For example ls -la specifies the LONG listing of ALL directory
contents.

I. The "|" character is called the PIPE character. This character is located on the key just above
the <Enter> key on the SGI keyboard (you mut also hold down the <shift> key). The pipe
character is used to direct the output of one command into the input of a second command. For
example,
ps -ef | grep biosym
first creates a list of processes (ps -ef) and then filters this list to show all lines that contain
"biosym" (grep biosym).

Abbreviations Used in this Guide


Text that appears on the screen is highlighted in bold. Text for which the user substitutes the
name of a file, directory, command, etc., appears in italics.
<control-x> type 'Ctrl' and 'x' keys at the same time
file.1, file.2 files named file.1 and file.2
dir.1, dir.2 directories named dir.1 and dir.2
command1, command2 commands named command1 and command2
pid1 process ID, listed by typing ps -ef

Files, directories, and commands can be specified without ambiguity by using the full pathname,
such as /usr/people/huffman/pdb/Crambin.pdb. If the file, subdirectory, or command exists in
the current directory, it can be specified using ONLY it's name. For example, if the current
directory is /usr/people/huffman/pdb/, then I can type Crambin.pdb to specify this file. Some
special files and directories, and almost all commands, can also be specified using ONLY it's
name regardless of your current directory, because they exist in special directories of the system.

Treebeard's Unix Cheat Sheet


People who use Windows without DOS, or a Macintosh, or PPP without a terminal, or an ISP's
menu without the Unix prompt are at a disadvantage. Something is happening, and they don't
know what it is. I like to know what's really going on, so I've been learning some Unix.

The Net is a Unix place. I'm no wizard, but I'm comfortable with basic commands and
occasionally type "rm" at my DOS prompt instead of "del". This is my Unix cheat sheet, so I can
remember. Uppercase and lowercase matter. These commands (mostly) work with my C-shell
account on RAIN. Your account might be different, especially if your prompt ends with a "$"
(Korn shell) rather than a "%", so be cautious. When I need help, I reach for the books UNIX in
a Nutshell (O'Reilly) and Unix Unbound by Harley Hahn (Osborne/McGraw Hill, 1994).

This page won't look right without table support. Most of this is available in a text version.

Help on any Unix command. RTFM!


man {command}
Type man ls to read the manual for the ls
command.
man {command} > {filename} Redirect help to a file to download.
whatis {command}
Give short description of command. (Not on
RAIN?)
apropos {keyword}
Search for all Unix commands that match
keyword, eg apropos file. (Not on RAIN?)

List a directory
ls {path}
It's ok to combine attributes, eg ls -laF gets a
long listing of all files with types.
ls {path_1} {path_2} List both {path_1} and {path_2}.
ls -l {path} Long listing, with date, size and permisions.
ls -a {path}
Show all files, including important .dot files
that don't otherwise show.
ls -F {path}
Show type of each file. "/" = directory, "*" =
executable.
ls -R {path} Recursive listing, with all subdirs.
ls {path} > {filename} Redirect directory to a file.
ls {path} | more Show listing one screen at a time.
dir {path} Useful alias for DOS people, or use with ncftp.

Change to directory
cd {dirname} There must be a space between.
cd ~ Go back to home directory, useful if you're lost.
cd .. Go back one directory.
cdup Useful alias, like "cd ..", or use with ncftp.

Make a new directory


mkdir {dirname}

Remove a directory
rmdir {dirname} Only works if {dirname} is empty.
rm -r {dirname} Remove all files and subdirs. Careful!

Print working directory


pwd
Show where you are as full path. Useful if
you're lost or exploring.

Copy a file or directory


cp {file1} {file2}
cp -r {dir1} {dir2} Recursive, copy directory and all subdirs.
cat {newfile} >> {oldfile} Append newfile to end of oldfile.

Move (or rename) a file


mv {oldfile} {newfile}
Moving a file and renaming it are the same
thing.
mv {oldname} {newname}

Delete a file
rm {filespec}
? and * wildcards work like DOS should. "?" is
any character; "*" is any string of characters.
ls {filespec} Good strategy: first list a group to make sure
rm {filespec}
it's what's you think...
...then delete it all at once.

Download with zmodem (Use sx with xmodem.)


sz [-a|b] {filename}
-a = ascii, -b = binary. Use binary for
everything. (It's the default?)
sz *.zip
Handy after downloading with FTP. Go talk to
your spouse while it does it's stuff.

Upload with zmodem (Use rx with xmodem.)


rz [-a|b] (filename}
Give rz command in Unix, THEN start upload
at home. Works fine with multiple files.

View a text file


more {filename} View file one screen at a time.
less {filename} Like more, with extra features.
cat {filename} View file, but it scrolls.
cat {filename} | more View file one screen at a time.
page {filename} Very handy with ncftp.
pico {filename} Use text editor and don't save.

Edit a text file.


pico {filename}
The same editor PINE uses, so you already
know it. vi and emacs are also available.

Create a text file.


cat > {filename}
Enter your text (multiple lines with enter are
ok) and press control-d to save.
pico {filename} Create some text and save it.

Compare two files


diff {file1} {file2} Show the differences.
sdiff {file1} {file2} Show files side by side.

Other text commands


grep '{pattern}' {file} Find regular expression in file.
sort {file1} > {file2} Sort file1 and save as file2.
sort -o {file} {file} Replace file with sorted version.
spell {file} Display misspelled words.
wc {file} Count words in file.

Find files on system


find {filespec} Works with wildcards. Handy for snooping.
find {filespec} > {filename} Redirect find list to file. Can be big!

Make an Alias
alias {name} '{command}'
Put the command in 'single quotes'. More useful
in your .cshrc file.

Wildcards and Shortcuts


*
Match any string of characters, eg page* gets
page1, page10, and page.txt.
?
Match any single character, eg page? gets
page1 and page2, but not page10.
[...]
Match any characters in a range, eg page[1-3]
gets page1, page2, and page3.
~
Short for your home directory, eg cd ~ will take
you home, and rm -r ~ will destroy it.
. The current directory.
.. One directory up the tree, eg ls ...

(You pipe a command to another command,


Pipes and Redirection and redirect it to a file.)
{command} > {file}
Redirect output to a file, eg ls > list.txt writes
directory to file.
Append output to an existing file, eg cat
{command} >> {file} update >> archive adds update to end of
archive.
{command} < {file} Get input from a file, eg sort < file.txt
Get input from file1, and write to file2, eg
{command} < {file1} > {file2} sort < old.txt > new.txt sorts old.txt and saves
as new.txt.
Pipe one command to another, eg ls | more gets
{command} | {command} directory and sends it to more to show it one
page at a time.

Permissions, important and tricky!


Unix permissions concern who can read a file or directory, write to it, and execute it.
Permissions are granted or withheld with a magic 3-digit number. The three digits
correspond to the owner (you); the group (?); and the world (everyone else).

Think of each digit as a sum:

execute permission =1
write permission =2
write and execute (1+2) =3
read permission =4
read and execute (4+1) =5
read and write (4+2) =6
read, write and execute (4+2+1) =7
Add the number value of the permissions you want to grant each group to make a three
digit number, one digit each for the owner, the group, and the world. Here are some useful
combinations. Try to figure them out!
chmod 600 {filespec}
You can read and write; the world can't. Good
for files.
chmod 700 {filespec}
You can read, write, and execute; the world
can't. Good for scripts.
chmod 644 {filespec}
You can read and write; the world can only
read. Good for web pages.
You can read, write, and execute; the world can
chmod 755 {filespec} read and execute. Good for programs you want
to share, and your public_html directory.

Permissions, another way


You can also change file permissions with letters:
u = user (yourself) g = group a = everyone
r = read w = write x = execute
chmod u+rw {filespec} Give yourself read and write permission
chmod u+x {filespec} Give yourself execute permission.
chmod a+rw {filespec} Give read and write permission to everyone.

Applications I use
finger {userid} Find out what someone's up to.
gopher Gopher.
irc IRC, but not available on RAIN.
lynx Text-based Web browser, fast and lean.
ncftp Better FTP.
pico {filename}
Easy text editor, but limited. vi and emacs are
available.
pine Email.
telnet {host} Start Telnet session to another host.
tin Usenet.
uudecode {filename} Do it on the server to reduce download size
uuencode {filename} about 1/3.
Chat with someone else online, eg ytalk
ytalk {userid} mkummel. Please use w first so you don't
interrupt a big download!
System info
date Show date and time.
df Check system disk capacity.
du
Check your disk usage and show bytes in each
directory.
more /etc/motd
Read message of the day, "motd" is a useful
alias..
printenv
Show all environmental variables (in C-shell%
- use set in Korn shell$).
quota -v Check your total disk use.
uptime Find out system load.
w Who's online and what are they doing?

Unix Directory Format


Long listings (ls -l) have this format:
- file
d directory, * executable
^ symbolic links (?) file size (bytes) file name / directory
^ ^ ^ ^ ^
drwxr-xr-x 11 mkummel 2560 Mar 7 23:25 public_html/
-rw-r--r-- 1 mkummel 10297 Mar 8 23:42 index.html
^
^^^ user permission (rwx) date and time last modified
^^^ group permission (rwx)
^^^ world permission (rwx)

How to Make an Alias


An alias lets you type something simple and do something complex. It's a shorthand for a
command. If you want to type "dir" instead of "ls -l" then type alias dir 'ls -l'. The single quotes
tell Unix that the enclosed text is one command.

Aliases are more useful if they're permanent so you don't have to think about them. You can do
this by adding the alias to your .cshrc file so they're automatically loaded when you start. Type
pico .cshrc and look for the alias section and add what you want. It will be effective when you
start. Just remember that if you make an alias with the name of a Unix command, that command
will become unavailable.

Here are a few aliases from my .cshrc file:

# enter your aliases here in the form:


# alias this means this

alias h history
alias m more
alias q quota -v
alias bye exit
alias ls ls -F
alias dir ls
alias cdup cd ..
alias motd more /etc/motd

How to Make a Script


A Unix script is a text file of commands that can be executed, like a .bat file in DOS. Unix
contains a powerful programming language with loops and variables that I don't really
understand. Here's a useful example.

Unix can't rename a bunch of files at once the way DOS can. This is a problem if you develop
Web pages on a DOS machine and then upload them to your Unix Server. You might have a
bunch of .htm files that you want to rename as .html files, but Unix makes you do it one by one.
This is actually not a defect. (It's a feature!) Unix is just being more consistent than DOS. So
make a script!

Make a text file (eg with pico) with the following lines. The first line is special. It tells Unix
what program or shell should execute the script. Other # lines are comments.

#! /bin/csh
# htm2html converts *.htm files to *.html
foreach f ( *.htm )
set base=`basename $f .htm`
mv $f $base.html
end
Save this in your home directory as htm2html (or whatever). Then make it user-executable by
typing chmod 700 htm2html. After this a * will appear by the file name when you ls -F, to
show that it's executable. Change to a directory with .htm files and type ~/htm2html, and it will
do its stuff.

Think about scripts whenever you find yourself doing the same tedious thing over and over.

Dotfiles (aka Hidden Files)


Dotfile names begin with a "." These files and directories don't show up when you list a directory
unless you use the -a option, so they are also called hidden files. Type ls -la in your home
directory to see what you have.

Some of these dotfiles are crucial. They initialize your shell and the programs you use, like
autoexec.bat in DOS and .ini files in Windows. rc means "run commands". These are all text
files that can be edited, but change them at your peril. Make backups first!

Here's some of what I get when I type ls -laF:

.addressbook my email addressbook.


.cshrc my C-shell startup info, important!
.gopherrc my gopher setup.
.history list of past commands.
.login login init, important!
.lynxrc my lynx setup for WWW.
.ncftp/ hidden dir of ncftp stuff.
.newsrc my list of subscribed newsgroups.
.pinerc my pine setup for email.
.plan text appears when I'm fingered, ok to edit.
.profile Korn shell startup info, important!
.project text appears when I'm fingered, ok to edit.
.signature my signature file for mail and news, ok to edit.
.tin/ hidden dir of my tin stuff for usenet.
.ytalkrc my ytalk setup.

DOS and UNIX commands


Action DOS UNIX
change directory cd cd
change file protection attrib chmod
compare files comp diff
copy file copy cp
delete file del rm
delete directory rd rmdir
directory list dir ls
edit a file edit pico
environment set printenv
find string in file find grep
help help man
make directory md mkdir
move file move mv
rename file ren mv
show date and time date, time date
show disk space chkdsk df
show file type cat
show file by screens type filename | more more
sort data sort sort

Unix commands
Note that there are thousands of commands available on a
typical unix box. In bash, just hit the "Tab" key twice and say
yes, to display the the commands currently available on your
machine. A standard unix operating system lists currently
thousands of commands. Type x to list all commands starting
with x. The following list contains some of the more frequently
used programs.

Access Control Miscellaneous

exit - terminate a shell (see "man sh" alias - define synonym commands
or "man csh") chquota - change disk quota on ACITS
logout - sign off; end session (C UNIX systems
shell and bash shell only;) chsh - change default login shell
passwd - change login password clear - clear terminal screen
rlogin - log in remotely to another echo - echo arguments
UNIX system pbm - portable bitmap manipulation
ssh - secure shell programs
slogin - secure version of rlogin popd - pop the directory stack (C
yppasswd - change login password in shell only)
yellow pages pushd - push directory on stack (C
shell only)
script - make typescript of terminal
Communications session
setenv - set an environment variable
(C shell only)
mail - send and receive mail stty - set terminal options
mesg - permit or deny terminal
messages and talk requests
pine - send and receive mail News/Networks
talk - talk to another logged-in user
write - write to another logged-in
user netstat - show network status
rsh - run shell or command on another
UNIX system
Programming Tools ssh - secure-shell version of rsh

as - assembler, specific to each Process Control


machine architecture
awk - pattern scanning and processing
language bg - put suspended process into
bc - online calculator background
cc - C compiler fg - bring process into foreground
csh - C shell command interpreter jobs - list processes
dbx - source-level debugging program ^y - suspend process at next input
f77 - Fortran compiler request
gdb - GNU Project debugger ^z - suspend current process
gprof - display profile of called
routines
kill - kill a process
ld - the UNIX loader
lex - generate lexical analysis Status Information
programs
lint - check C source code
make - maintain large programs clock - determine processor time
maple - symbolic mathematics program date - show date and time
math - symbolic mathematics program df - summarize free disk space
nice - run a command at low priority du - summarize disk space used
(see "man nice" or "man csh") env - display environment
nohup - run a command immune to finger - look up user information
hangups history - list previously issued
pc - Pascal compiler (xlp on ADS) commands
perl - Popular script interpreter last - indicate last login of users
prof - display profile data lpq - examine spool queue
python - Python programming language manpath - show search path for man
sh - Bourne shell command interpreter pages
yacc - generate input parsing programs printenv - print out environment
xcalc - graphical calulator under x ps - show process status
pwd - print full pathname of working
directory
Documentation set - set shell variables (C shell,
bash, or ksh)
spend - lists year-to-date ACITS UNIX
apropos - locate commands by keyword charges
lookup stty - set terminal options
find - locate file (i.e. find . -name time - timing programs
*.tex -print) top - list top cpu processes
info - start the info explorer program uptime - show system load, how long
man - find manual information about system has been up
commands w - show who is on system, what
whatis - describe what a command is command each job is executing
whereis - locate source, binary, or who - show who is logged onto the
man page for a program system
Editors whois - Internet user name directory
service
whoami - who owns the shell
emacs - screen-oriented text editor
pico - screen-oriented text editor
(renamed called nano) Image Processing
sed - stream-oriented text editor
vi - full-screen text editor
vim - full-screen text editor ("vi- gimp - photoshop type image processing
improved") program
File and Directory Management xfig - drawing program
xv - image viewer
xvscan - scan picture
cd - change working directory xpaint - paint program
chmod - change the protection of a kpaint - kde paint program
file or directory
chown - change owner (or group) of a
file or directory Sound
chgrp - change group of a file or
directory
cmp - compare two files mplayer - mpg player
comm - select/reject lines common to realplay - realaudio player
two sorted files timidity - midi to wav converter and
cp - copy files player
crypt - encrypt/decrypt files (CCWF xmms - mp3 player
only)
diff - compare the contents of two
ASCII files Text Processing
file - determine file type
grep - search a file for a pattern
gzip - compress or expand files abiword - open source word processor
ln - make a link to a file addbib - create or extend
ls - list the contents of a directory bibliographic database
lsof - list of open files col - filter reverse line feeds
mkdir - create a directory diction - identify wordy sentences
mv - move or rename files and diffmk - mark differences between
directories files
pwd - show the full pathname of your dvips - convert TeX DVI files into
working directory PostScript
quota - display disk usage and limits explain - explain phrases found by
rm - delete (remove) files diction program
rmdir - delete (remove) directories grap - pic preprocessor for drawing
stat - status of file (i.e. last graphs
access) hyphen - find hyphenated words
sync - flush filesystem buffers ispell - check spelling interactively
sort - sort or merge files latex - format text in LaTeX (based on
tar - create or extract archives TeX)
tee - copy input to standard output pdfelatex - latex with pdf output
and other files latex2html - Latex to html
tr - translate characters lookbib - find bibliography references
umask - change default file macref - make cross-reference listing
protections of nroff/troff macro files
uncompress - restore compressed file ndx - create a subject-page index for
uniq - report (or delete) repeated a document
lines in a file neqn - format mathematics with nroff
wc - count lines, words, and nroff - format text for simple display
characters in a file pic - make simple pictures for troff
input
psdit - filter troff output for Apple
File Display and Printing LaserWriter
ptx - make permuted index (not on
CCWF)
cat - show the contents of a file; refer - insert references from
catenate files bibliographic databases
fold - fold long lines to fit output roffbib - run off bibliographic
device database
head - show first few lines of a file sortbib - sort bibliographic database
lpq - examine the printer spooling spell - find spelling errors
queue ispell - interactive spell checker
lpr - print a file style - analyze surface
lprm - remove jobs from the printer characteristics of a document
spooling queue tbl - format tables for nroff/troff
more - display a file, one screen at a tex - format text
time tpic - convert pic source files into
less - like more with more features TeX commands
wget - grab webpage

X windows
page - like "more", but prints screens
top to bottom
pr - paginate a file for printing grabmode - info on screen: i.e.
tail - show the last part of a file "1152x864" 51.213kHz/56.59Hz
zcat - display a compressed file import - grab window (i.e. import
xv - show print, manipulate images ppm:- >out.ppm)
gv - show ps and pdf files xdpyinfo - number of colors
xpdf = shopw pdf files (use gv) xkill - kill xwindow
xlock - lock screen
xterm - xterminal
File Transfer xwininfo - information on open window

ftp - transfer files between network


Web
hosts
rsync - fast and flexible sync
between computers html2ps - html to ps
scp - secure version of rcp latex2html - latex to html translator
lynx - text based webbrowser
netscape - webbrowser
sitecopy - sitecopy is for easily
maintaining remote web sites.
weblint - html sytax and style checker

Command Description
a2p Creates a Perl script from an awk script.
ac Prints statistics about users' connect time.
alias Create a name for another command or long command string.
ar Maintain portable archive or library.
arch Display the architecture of the current host.
arp Manipulate the system ARP cache.
as An assembler.
at Command scheduler.
awk Awk script processing program.
basename Deletes any specified prefix from a string.
bash Command Bourne interpreter
bc Calculator.
bdiff Compare large files.
bfs Editor for large files.
bg Continues a program running in the background.
biff Enable / disable incoming mail notifications.
break Break out of while, for, foreach, or until loop.
bs Battleship game.
bye Alias often used for the exit command.
cal Calendar
calendar Display appointments and reminders.
cancel Cancels a print job.
cat View and/or modify a file.
cc C compiler.
cd Change directory.
chdir Change directory.
checkeq Language processors to assist in describing equations.
checknr Check nroff and troff files for any errors.
Modify your own information or if super user or root modify another
chfn
users information.
chgrp Change a groups access to a file or directory.
chkey Change the secure RPC key pair.
chmod Change the permission of a file.
chown Change the ownership of a file.
chsh Change login shell.
cksum Display and calculate a CRC for files.
clear Clears screen.
cls Alias often used to clear a screen.
cmp Compare files.
col Reverse line-feeds filter.
comm Compare files and select or reject lines that are common.
compress Compress files on a computer.
continue Break out of while, for, foreach, or until loop.
copy Copy files.
cp Copy files.
cpio Creates archived CPIO files.
crontab Create and list files that you wish to run on a regular schedule.
csh Execute the C shell command interpreter
csplit Split files based on context.
ctags Create a tag file for use with ex and vi.
Calls or connects to another Unix system, terminal or non-Unix
cu
system.
curl Transfer a URL.
cut Cut out selected fields of each line of a file.
date Tells you the date and time in Unix.
dc An arbitrary precision arithmetic package.
df Display the available disk space for each mount.
deroff Removes nroff/troff, tbl, and eqn constructs.
dhclient Dynamic Host Configuration Protocol Client.
diff Displays two files and prints the lines that are different.
dig DNS lookup utility.
dircmp Lists the different files when comparing directories.
dirname Deliver portions of path names.
dmesg Print or control the kernel ring buffer.
dos2unix Converts text files between DOS and Unix formats.
dpost Translates files created by troff into PostScript.
du Tells you how much space a file occupies.
echo Displays text after echo to the terminal.
ed Line oriented file editor.
edit Text editor.
egrep Search a file for a pattern using full regular expressions.
elm Program command used to send and receive e-mail.
emacs Text editor.
enable Enables / Disables LP printers.
env Displays environment variables.
eqn Language processors to assist in describing equations.
ex Line-editor mode of the vi text editor.
exit Exit from a program, shell or log you out of a Unix network.
expand Expand copies of file s.
expr Evaluate arguments as an expression.
The FC utility lists or edits and re-executes, commands previously
fc
entered to an interactive sh.
fg Continues a stopped job by running it in the foreground
fgrep Search a file for a fixed-character string.
file Tells you if the object you are looking at is a file or if it is a directory.
Finds one or more files assuming that you know their approximate
find
filenames.
List info about machines that respond to SMB name queries on a
findsmb
subnet.
finger Lists information about the user.
fmt Simple text formatters.
fold Filter for folding lines.
Shell built-in functions to repeatedly execute action(s) for a selected
for
number of times.
Shell built-in functions to repeatedly execute action(s) for a selected
foreach
number of times.
fromdos Converts text files between DOS and Unix formats.
fsck Check and repair a Linux file system.
ftp Enables ftp access to another terminal.
getfacl Display discretionary file information.
gprof The gprof utility produces an execution profile of a program.
grep Finds text within a file.
groupadd Creates a new group account.
groupdel Enables a super user or root to remove a group.
groupmod Enables a super user or root to modify a group.
gunzip Expand compressed files.
gview A programmers text editor.
gvim A programmers text editor.
gzip Compress files.
halt Stop the computer.
hash Remove internal hash table.
hashstat Display the hash stats.
head Displays the first ten lines of a file, unless otherwise stated.
If computer has online help documentation installed this command
help
will display it.
history Display the history of commands typed.
host DNS lookup utility.
hostid Prints the numeric identifier for the current host.
hostname Set or print name of current host system.
id Shows you the numeric user and group ID on BSD.
ifconfig Sets up network interfaces. 
ifdown take a network interface down
ifup bring a network interface up
isalist Display the native instruction sets executable on this platform.
jobs List the jobs currently running in the background.
join Joins command forms together.
keylogin Decrypt the user's secret key.
kill Cancels a job.
ksh Korn shell command interpreter.
ld Link-editor for object files.
ldd List dynamic dependencies of executable files or shared objects.
less Opposite of the more command.
lex Generate programs for lexical tasks.
link Calls the link function to create a link to a file.
ln Creates a link to a file.
Allows you to exit from a program, shell or log you out of a Unix
lo
network.
locate List files in databases that match a pattern.
login Signs into a new system.
logname Returns users login name.
logout Logs out of a system.
lp Prints a file on System V systems.
lpadmin Configure the LP print service.
lpc Line printer control program.
lpq Lists the status of all the available printers.
lpr Submits print requests.
lprm Removes print requests from the print queue.
lpstat Lists status of the LP print services.
ls Lists the contents of a directory.
mach Display the processor type of the current host.
mail One of the ways that allows you to read/send E-Mail.
mailcompat Provide SunOS 4.x compatibility for the Solaris mailbox format.
mailx Mail interactive message processing system.
make Executes a list of shell commands associated with each target.
man Display a manual of a command.
mesg Control if non-root users can send text messages to you.
mii-tool View, manipulate media-independent interface status.
mkdir Create a directory.
mkfs Build a Linux file system, usually a hard disk partition.
more Displays text one screen at a time.
mount Disconnects a file systems and remote resources.
mt Magnetic tape control.
mv Renames a file or moves it from one directory to another directory.
nc TCP/IP swiss army knife.
neqn Language processors to assist in describing equations.
netstat Shows network status.
newalias Install new elm aliases for user and/or system.
newform Change the format of a text file.
newgrp Log into a new group.
nice Invokes a command with an altered scheduling priority.
niscat Display NIS+ tables and objects.
nischmod Change access rights on a NIS+ object.
nischown Change the owner of a NIS+ object.
nischttl Change the time to live value of a NIS+ object.
nisdefaults Display NIS+ default values.
nisgrep Utilities for searching NIS+ tables.
nismatch Utilities for searching NIS+ tables.
nispasswd Change NIS+ password information.
nistbladm NIS+ table administration command.
nmap Network exploration tool and security / port scanner.
nohup Runs a command even if the session is disconnected or the user logs
out.
nroff Formats documents for display or line-printer.
nslookup Queries a name server for a host or domain lookup.
Execute a command on a remote system, but with the local
on
environment.
onintr Shell built-in functions to respond to (hardware) signals.
optisa Determine which variant instruction set is optimal to use.
pack Shrinks file into a compressed file.
Display the size of a page of memory in bytes, as returned by
pagesize
getpagesize.
passwd Allows you to change your password.
paste Merge corresponding or subsequent lines of files.
Read / write and writes lists of the members of archive files and copy
pax
directory hierarchies.
pcat Compresses file.
Perl is a programming language optimized for scanning arbitrary text
perl
files, extracting information from those text files.
pg Files perusal filters for CRTs.
Examine the active processes on the system and reports the process
pgrep
IDs of the processes
Simple and very easy to use text editor in the style of the Pine
pico
Composer.
pine Command line program for Internet News and Email.
ping Sends ICMP ECHO_REQUEST packets to network hosts.
Examine the active processes on the system and reports the process
pkill
IDs of the processes
poweroff Stop the computer.
pr Formats a file to make it look better when printed.
priocntl Display's or set scheduling parameters of specified process(es)
printf Write formatted output.
ps Reports the process status.
Display the internal version information of dynamic objects within an
pvs
ELF file.
pwd Print the current working directory.
Allows you to exit from a program, shell or log you out of a Unix
quit
network.
rcp Copies files from one computer to another computer.
reboot Stop the computer.
red Line oriented file editor.
Recomputes the internal hash table of the contents of directories
rehash
listed in the path.
remsh Runs a command on another computer.
Shell built-in functions to repeatedly execute action(s) for a selected
repeat
number of times.
rgview A programmers text editor.
rgvim A programmers text editor.
Establish a remote connection from your terminal to a remote
rlogin
machine.
rm Deletes a file without confirmation (by default).
rmail One of the ways that allows you to read/send E-Mail.
rmdir Deletes a directory.
rn Reads newsgroups.
route Show / manipulate the IP routing table.
rpcinfo Report RPC information.
rsh Runs a command on another computer.
rsync Faster, flexible replacement for rcp.
rview A programmers text editor.
rvim A programmers text editor.
s2p Convert a sed script into a Perl script.
Graphically displays the system activity data stored in a binary data
sag
file by a previous sar run.
sar Displays the activity for the CPU.
script Records everything printed on your screen.
sdiff Compares two files, side-by-side.
sed Allows you to use pre-recorded commands to make changes to text.
sendmail Sends mail over the Internet.
set Set the value of an environment variable.
setenv Set the value of an environment variable.
setfacl Modify the Access Control List (ACL) for a file or files.
settime Change file access and modification time.
sftp Secure file transfer program.
sh Runs or processes jobs through the Bourne shell.
shred Delete a file securely, first overwriting it to hide its contents.
shutdown Turn off the computer immediately or at a specified time.
sleep Waits a x amount of seconds.
slogin OpenSSH SSH client (remote login program).
smbclient An ftp-like client to access SMB/CIFS resources on servers.
sort Sorts the lines in a text file.
Looks through a text file and reports any words that it finds in the text
spell
file that are not in the dictionary.
split Split a file into pieces.
stat Display file or filesystem status.
stop Control process execution.
strip Discard symbols from object files.
stty Sets options for your terminal.
su Become super user or another user.
sysinfo Get and set system information strings.
sysklogd Linux system logging utilities.
tabs Set tabs on a terminal.
tail Delivers the last part of the file.
talk Talk with other logged in users.
tac Concatenate and print files in reverse.
tar Create tape archives and add or extract files.
tbl Preprocessor for formatting tables for nroff or troff.
tcopy Copy a magnetic tape.
tcpdump Dump traffic on a network.
tee Read from an input and write to a standard output or file.
telnet Uses the telnet protocol to connect to another remote computer.
time Used to time a simple command.
The timex command times a command; reports process data and
timex
system activity.
todos Converts text files between DOS and Unix formats.
top Display Linux tasks.
touch Change file access and modification time.
tput Initialize a terminal or query terminfo database.
tr Translate characters.
traceroute Print the route packets take to network host.
troff Typeset or format documents.
ul Reads the named filenames or terminal and does underlining.
umask Get or set the file mode creation mask.
unalias Remove an alias.
unhash Remove internal hash table.
uname Print name of current system.
uncompres
Uncompressed compressed files.
s
uniq Report or filter out repeated lines in a file.
unmount Crates a file systems and remote resources.
unpack Expands a compressed file.
untar Create tape archives and add or extract files.
until Execute a set of actions while/until conditions are evaluated TRUE.
useradd Create a new user or updates default new user information.
userdel Remove a users account.
usermod Modify a users account.
vacation Reply to mail automatically.
vedit Screen-oriented (visual) display editor based on ex.
vgrind Grind nice program listings
vi Screen-oriented (visual) display editor based on ex.
vim A programmers text editor.
view A programmers text editor.
w Show who is logged on and what they are doing.
wait Await process completion.
wc Displays a count of lines, words, and characters in a file
whereis Locate a binary, source, and manual page files for a command.
Repetitively execute a set of actions while/until conditions are
while
evaluated TRUE.
which Locate a command.
who Displays who is on the system.
whois Internet user name directory service.
write Send a message to another user.
X Execute the X windows system.
xfd Display all the characters in an X font.
xlsfonts Server font list displayer for X.
xset User preference utility for X.
xterm Terminal emulator for X.
xrdb X server resource database utility.
yacc Short for yet another compiler-compiler, yacc is a compiler.
yes Repeatedly output a line with all specified STRING(s), or 'y'.
yppasswd Changes network password in the NIS database.
zcat Compress files.

Unix Command Summary


See the Unix tutorial for a leisurely, self-paced introduction on how to use the commands listed below.
For more documentation on a command, consult a good book, or use the man pages. For example, for
more information on grep, use the command man grep.

Contents
 cat --- for creating and displaying short files
 chmod --- change permissions

 cd --- change directory

 cp --- for copying files

 date --- display date

 echo --- echo argument

 ftp --- connect to a remote machine to download or upload files

 grep --- search file

 head --- display first part of file

 ls --- see what files you have

 lpr --- standard print command (see also print )

 more --- use to read files

 mkdir --- create directory

 mv --- for moving and renaming files

 ncftp --- especially good for downloading files via anonymous ftp.

 print --- custom print command (see also lpr )

 pwd --- find out what directory you are in


 rm --- remove a file

 rmdir --- remove directory

 rsh --- remote shell

 setenv --- set an environment variable

 sort --- sort file

 tail --- display last part of file

 tar --- create an archive, add or extract files

 telnet --- log in to another machine

 wc --- count characters, words, lines

cat

This is one of the most flexible Unix commands. We can use to create, view and concatenate
files. For our first example we create a three-item English-Spanish dictionary in a file called
"dict."

% cat >dict
red rojo
green verde
blue azul
<control-D>
%

<control-D> stands for "hold the control key down, then tap 'd'". The symbol > tells the computer
that what is typed is to be put into the file dict. To view a file we use cat in a different way:

% cat dict
red rojo
green verde
blue azul
%
If we wish to add text to an existing file we do this:

% cat >>dict
white blanco
black negro
<control-D>
%

Now suppose that we have another file tmp that looks like this:

% cat tmp
cat gato
dog perro
%
Then we can join dict and tmp like this:

% cat dict tmp >dict2

We could check the number of lines in the new file like this:

% wc -l dict2
8

The command wc counts things --- the number of characters, words, and line in a file.

chmod

This command is used to change the permissions of a file or directory. For example to make a
file essay.001 readable by everyone, we do this:

% chmod a+r essay.001

To make a file, e.g., a shell script mycommand executable, we do this

% chmod +x mycommand
Now we can run mycommand as a command.

To check the permissions of a file, use ls -l . For more information on chmod, use man chmod.

cd

Use cd to change directory. Use pwd to see what directory you are in.

% cd english
% pwd
% /u/ma/jeremy/english
% ls
novel poems
% cd novel
% pwd
% /u/ma/jeremy/english/novel
% ls
ch1 ch2 ch3 journal scrapbook
% cd ..
% pwd
% /u/ma/jeremy/english
% cd poems
% cd
% /u/ma/jeremy

Jeremy began in his home directory, then went to his english subdirectory. He listed this
directory using ls , found that it contained two entries, both of which happen to be diretories. He
cd'd to the diretory novel, and found that he had gotten only as far as chapter 3 in his writing.
Then he used cd .. to jump back one level. If had wanted to jump back one level, then go to
poems he could have said cd ../poems. Finally he used cd with no argument to jump back to his
home directory.

cp
Use cp to copy files or directories.

% cp foo foo.2
This makes a copy of the file foo.

% cp ~/poems/jabber .

This copies the file jabber in the directory poems to the current directory. The symbol "." stands
for the current directory. The symbol "~" stands for the home directory.

date
Use this command to check the date and time.

% date
Fri Jan 6 08:52:42 MST 1995

echo

The echo command echoes its arguments. Here are some examples:

% echo this
this
% echo $EDITOR
/usr/local/bin/emacs
% echo $PRINTER
b129lab1

Things like PRINTER are so-called environment variables. This one stores the name of the default
printer --- the one that print jobs will go to unless you take some action to change things. The
dollar sign before an environment variable is needed to get the value in the variable. Try the
following to verify this:

% echo PRINTER
PRINTER

ftp

Use ftp to connect to a remote machine, then upload or download files. See also: ncftp

Example 1: We'll connect to the machine fubar.net, then change director to mystuff, then
download the file homework11:

% ftp solitude
Connected to fubar.net.
220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT
1994) ready.
Name (solitude:carlson): jeremy
331 Password required for jeremy.
Password:
230 User jeremy logged in.
ftp> cd mystuff
250 CWD command successful.
ftp> get homework11
ftp> quit

Example 2: We'll connect to the machine fubar.net, then change director to mystuff, then
upload the file collected-letters:

% ftp solitude
Connected to fubar.net.
220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT
1994) ready.
Name (solitude:carlson): jeremy
331 Password required for jeremy.
Password:
230 User jeremy logged in.
ftp> cd mystuff
250 CWD command successful.
ftp> put collected-letters
ftp> quit

The ftp program sends files in ascii (text) format unless you specify binary mode:

ftp> binary
ftp> put foo
ftp> ascii
ftp> get bar
The file foo was transferred in binary mode, the file bar was transferred in ascii mode.
grep

Use this command to search for information in a file or files. For example, suppose that we have
a file dict whose contents are

red rojo
green verde
blue azul
white blanco
black negro
Then we can look up items in our file like this;

% grep red dict


red rojo
% grep blanco dict
white blanco
% grep brown dict
%

Notice that no output was returned by grep brown. This is because "brown" is not in our
dictionary file.

Grep can also be combined with other commands. For example, if one had a file of phone
numbers named "ph", one entry per line, then the following command would give an alphabetical
list of all persons whose name contains the string "Fred".

% grep Fred ph | sort


Alpha, Fred: 333-6565
Beta, Freddie: 656-0099
Frederickson, Molly: 444-0981
Gamma, Fred-George: 111-7676
Zeta, Frederick: 431-0987
The symbol "|" is called "pipe." It pipes the output of the grep command into the input of the sort
command.

For more information on grep, consult

% man grep

head

Use this command to look at the head of a file. For example,

% head essay.001

displays the first 10 lines of the file essay.001 To see a specific number of lines, do this:
% head -n 20 essay.001
This displays the first 20 lines of the file.

ls

Use ls to see what files you have. Your files are kept in something called a directory.

% ls
foo letter2
foobar letter3
letter1 maple-assignment1
%

Note that you have six files. There are some useful variants of the ls command:

% ls l*
letter1 letter2 letter3
%

Note what happened: all the files whose name begins with "l" are listed. The asterisk (*) is the "
wildcard" character. It matches any string.

lpr

This is the standard Unix command for printing a file. It stands for the ancient "line printer." See

% man lpr

for information on how it works. See print for information on our local intelligent print
command.

mkdir
Use this command to create a directory.

% mkdir essays
To get "into" this directory, do

% cd essays
To see what files are in essays, do this:

% ls
There shouldn't be any files there yet, since you just made it. To create files, see cat or emacs.

more

More is a command used to read text files. For example, we could do this:

% more poems

The effect of this to let you read the file "poems ". It probably will not fit in one screen, so you
need to know how to "turn pages". Here are the basic commands:

 q --- quit more


 spacebar --- read next page

 return key --- read next line

 b --- go back one page

For still more information, use the command man more.

mv

Use this command to change the name of file and directories.

% mv foo foobar

The file that was named foo is now named foobar

ncftp

Use ncftp for anonymous ftp --- that means you don't have to have a password.

% ncftp ftp.fubar.net
Connected to ftp.fubar.net
> get jokes.txt

The file jokes.txt is downloaded from the machine ftp.fubar.net.


print
This is a moderately intelligent print command.

% print foo
% print notes.ps
% print manuscript.dvi

In each case print does the right thing, regardless of whether the file is a text file (like foo ), a
postcript file (like notes.ps, or a dvi file (like manuscript.dvi. In these examples the file is
printed on the default printer. To see what this is, do

% print
and read the message displayed. To print on a specific printer, do this:

% print foo jwb321


% print notes.ps jwb321
% print manuscript.dvi jwb321
To change the default printer, do this:

% setenv PRINTER jwb321

pwd
Use this command to find out what directory you are working in.

% pwd
/u/ma/jeremy
% cd homework
% pwd
/u/ma/jeremy/homework
% ls
assign-1 assign-2 assign-3
% cd
% pwd
/u/ma/jeremy
%

Jeremy began by working in his "home" directory. Then he cd 'd into his homework
subdirectory. Cd means " change directory". He used pwd to check to make sure he was in the
right place, then used ls to see if all his homework files were there. (They were). Then he cd'd
back to his home directory.

rm
Use rm to remove files from your directory.
% rm foo
remove foo? y
% rm letter*
remove letter1? y
remove letter2? y
remove letter3? n
%

The first command removed a single file. The second command was intended to remove all files
beginning with the string "letter." However, our user (Jeremy?) decided not to remove letter3.

rmdir

Use this command to remove a directory. For example, to remove a directory called "essays", do
this:

% rmdir essays

A directory must be empty before it can be removed. To empty a directory, use rm.

rsh

Use this command if you want to work on a computer different from the one you are currently
working on. One reason to do this is that the remote machine might be faster. For example, the
command

% rsh solitude

connects you to the machine solitude. This is one of our public workstations and is fairly fast.

See also: telnet

setenv
% echo $PRINTER
labprinter
% setenv PRINTER myprinter
% echo $PRINTER
myprinter

sort
Use this commmand to sort a file. For example, suppose we have a file dict with contents

red rojo
green verde
blue azul
white blanco
black negro
Then we can do this:

% sort dict
black negro
blue azul
green verde
red rojo
white blanco
Here the output of sort went to the screen. To store the output in file we do this:

% sort dict >dict.sorted


You can check the contents of the file dict.sorted using cat , more , or emacs .

tail

Use this command to look at the tail of a file. For example,

% tail essay.001

displays the last 10 lines of the file essay.001 To see a specific number of lines, do this:

% tail -n 20 essay.001
This displays the last 20 lines of the file.

tar

Use create compressed archives of directories and files, and also to extract directories and files
from an archive. Example:

% tar -tvzf foo.tar.gz

displays the file names in the compressed archive foo.tar.gz while

% tar -xvzf foo.tar.gz


extracts the files.
telnet

Use this command to log in to another machine from the machine you are currently working on.
For example, to log in to the machine "solitude", do this:

% telnet solitude

See also: rsh.

wc

Use this command to count the number of characters, words, and lines in a file. Suppose, for
example, that we have a file dict with contents

red rojo
green verde
blue azul
white blanco
black negro
Then we can do this

% wc dict
5 10 56 tmp

This shows that dict has 5 lines, 10 words, and 56 characters.

The word count command has several options, as illustrated below:

% wc -l dict
5 tmp
% wc -w dict
10 tmp
% wc -c dict
56 tmp

dummy
Under construction

Basic Unix Commands

Unix commands are the first thing needed by a unix  sysadmin  who are  starting to work in
unix operating system . Unix operating systems  comes with online manual  system which can
be used to see the command details , syntax options and examples on while working on a unix 
system. Unix manual can be accessed using man <command name> and it requires the man
package   installed and MANPATH  set to man  directories. The manual page directories may
differ in different unix operating systems and  man package may not be installed in all systems .
Following are a few of the most popular and useful commands used in unix operating system
wildcard characters

* The * wildcard character substitutes for one or more characters in


a filename. For instance, to list all the files in your directory that
end with .c, enter the command
ls *.c

? ? (question mark) serves as  wildcard character for any one


character in a filename. For instance, if you have files named
prog1, prog2, prog3, and prog3  in your directory, the Unix
command:

ls prog?

dir
Change cd dir      Change to directory d
Make mkdir dir        Create new directory d
Move mv dir1 dir2 Rename directory d1 as d2
Remove rmdir dir Remove directory d

file  
list , no details only
ls   filename , filename with wildcard character/s.       
names
list , details ls -1   filename , filename with wildcard character/s.   
move  to directory mv filename    dirname     (wildcard character/s supported)
copy file to
other/current  cp file  directory/newfile    or cp directory/oldfile  .
directory
rm  file  ,  rm -rf  directory  - Recursively remove files & directly
Delete the file
without any warning.
file file  filename  , file command tries to determine the file type ,
text , executable etc after comparing the values in /etc/magic .

File  
edit/create/view
vi  - vi  full screen
vi  filename   , Opens a existing file or creates
editor 
ed - Line Text editor ed  filename
count - Line, word, & wc  filename
char
Text content display
- List contents of file at cat  filename
once
Text content display
by screen :  List
more  filename
contents of file  screen
by screen 
Concatenate -  file1 &
cat file1 file2 >file3  
file2 into file3

File operation
Change
read/write/execute chmod mode file  
mode of fil
chown chown [-R] [-h] owner[:group] file
move (rename )  file mv file1  file2     Rename file file1 as file2
Remove rm file  Delete (remove) file f
Compare two files cmp file1 file2   
Copy file file1 into
cp file1 file2      
file2
Sort Alphabetically sort file
Sort Numerically sort -n file
Split f into n-line
split  [-n]  f
pieces
match pattern grep pattern file     Outputs lines that
Lists file differences diff file1 file2     
head f Output
beginning of file
head  file

Output end of file tail file

PROCESS
Suspend current
CTRL/z *       
process
Interrupt processes CTRL/c *      
Stop screen scrolling CTRL/s *      
Resume screen
CTRL/q *       
scrolling
Sleep for n seconds sleep n    
Print list of jobs jobs
Kill job n kill %     
Remove process n kill  -9 n  
status process status
ps    
stats
Resume background
bg  [%n]       
job n
Resume foreground
fg  [%n]       
job n
Exit from shell exit   

User admin  
 add a new user login # useradd -u 655 -g 20 -d /home/ttes testlogin  loginname
to the system -u is userid , if not specified system takes highest available .
-g group id should be existing in /etc/group , if not specified other or
user is assigned.
-d home directory , default is to use user as the directory name under
the home directory.
loginname - new login name to be created .
#useradd testlogin    will create a user by the name 'testlogin' with all
default values .
password Change passwd  <user>
alias (csh/tcsh) -
alias name1 name2     
Create command
alias (ksh/bash) -
alias name1="name2"   
Create alias command
alias - Remove alias   unalias name1[na2...]

printer  
 Output file f to line
lp -d printer file   
printer
   
System  Status  
Display disk quota quota   
Print date & time date    
List logged in users who     
Display current user whoami  
Output user
finger  [username]    
information
Display recent
history
commands
Environment
 
Variable
set command alone displays the environment variables, it is used
set
to set options in ksh   like set -o vi 
export  export variable ,  export  makes variable visible in sub shells.
Set environment 
variable  (csh/tcsh)  sentenv name v
to value v
Set environment 
variable  (ksh/bash)  export name=v      example :  export TERM=vt100
to value v

Connectivity  
Connecting to a  $telnet hostname/ip address      or  $telnet
remote host Telnet brings up the login prompt of remote host and  expects you
to enter your user name & password .Without argument it enters
command mode (telnet>) and accepts command listed by ? at
telnet> prompt.
Communication is not encrypted between two hosts.
Securely connecting to ssh  username@hostname  or ssh -l username hostname
a remote host Depending on ssh setting for your account you may or may not be
  asked a password to login. Your login/passwd will be same login
password as you would use with telnet connection.
Communication is encrypted between two hosts so if someone
intercepts your communication he will not be able to use it.
Copy files from/to ftp hostname
remote host ftp expects you to enter  your username/passwd or if it is ftp only
account it will require ftp account password .
put , mput (multipleput) command is used to transfer files to
remote host.
get , mget (multipleput) command is used to transfer files from
remote host.
ftp allows some limited number of commands to be executed at
ftp> prompt & summary of ftp command can be found by using ?
at ftp>  prompt
Securely copy files sftp username@hostname:remotefile  localfile 
from/to remote host Communication is encrypted between two hosts.
 
Test the tcp/ip  ping hostname
connectivity If you can ping a host the host is reachable from the machine that
between two hosts you are using .
Router/firewall configuration may prevent ping to succeed .

Backup and 
 
Restore
backup and restore tar tvf filename.tar   ---  View the table of content of a tar
using tar , archive
TApeaRchive tar xvf filename.tar   --- Extract content of a tar archive
tar cvf filename.tar  file1 file2  file3 --- Create a tar archive
called filename.tar using file1, file2,file3 .
tar can't copy the special files , device files .Not suitable for taking root
backup.
backup and restore cpio is mostly used in conjunction with other commands to generate a
using cpio  , list of files to be copied :
CopyInputOutput #ls | cpio -o > /dev/rmt/c0t0d0 -- Copy the contents of a
directory into a tape archive:
#find . -depth -print | cpio -pd newdir --- copy entire directory
to other place:
#find . -cpio /dev/rmt/c0t0d0 --- Copy files in current directory
to a tape
cpio can copy special files and hence useful in taking root backup
containing device file.
Find files  , directories
find  files , Find  command is used to find the files , directories and to run
directories commands on the list of files thus generated .By default, find does
not follow symbolic links.
 
find . -name *.log -print    --- Simple find to list log files
find . -name '*.log' -exec rm  {} \;  -- Simple find to find log
files and delete them .
find accepts a long list of options to find the files based on different
parameters such as create time , modified time , of certain size etc.
Please refer to man find for more option.

The following list of basic unix commandshas been compiled by Per Kistler.

Directory ::
Show current directory pwd
Show content of directory ls -al
Changing directory cd <newdir>
Creating directory mkdir <dir>
Deleting directory if empty rmdir <dir>
Deleting directory if full rm -r <dir>
Moving directory mv <olddir> <newdir>
Copy directory cp -r <olddir> <newdir>
Files ::
Show file entry ls -al <file>
Delete file rm -i <file>
Move file mv <file> <path>
Copy file cp <file> <newfile>
Rename file mv <oldfile> <newfile>
Show file content at once cat <file>
Show file content page wise more <file>
Show file with long lines cat <file> | fold
Show first 20 lines of file head -20 <file>
Show last 20 lines of file tail -20 <file>
Edit file <editorname> <file>
Edit file with vi vi <file>
Give all file permissions to yourself chmod 700 <file>
The above even into subdirectories chmod -R 700 <dir>
Open file for reading and executing for all chmod 644 <file>
Starting file as program <filneame> <arguments>
Find word in file grep <word> <file>
Find all files which contain a word grep -l <word> *
Find abstract pattern: ab 2 digits cd grep 'ab[0-9][0-9]cd' <file>
Comparing two files diff <file1> <file2>
Updating the date of a file touch <file>
Giving a specific date to a file touch 0101010199 <file>
Help ::
Getting help about a command man <command>
Find command related to a term man -k <term>
Where is a particular program if it is in the path which <commandname>
Is a <name> a unix command or an alias in ksh whence <commandname>
Aliases ::
Making an alias in csh/tcsh alias <aliasname> '<long_command>'
Making an alias where the arguments go in the
alias <aliasneme> '<command> \!* <other>'
middle
Making an alias in sh/bash/ksh alias <aliasname>='<long_command>'
Using an alias <aliasname> <arguments>
Use command instead of it's alias \<command>
Showing all aliases alias
Remove an alias unalias <aliasname>
Adjustments ::
See environment variables env
Setting the term variable if vi doesn't work setenv term vt100
Opening the X-server for X-clients xhost +
Setting the display for X-clients setenv display <computer>:0.0
Internet ::
Telnet to another computer telnet <computername>
rlogin -l <username_there>
Rlogin to another computer
<computername>
Browsing the net with netscape netscape
Check whether someone is logged in somwhere finger user@host.domain
Check for all people on another computer finger @host.domain
Talk to another person on another computer talk user@host.domain
Ftp building up connection ftp <computername>
Ftp adjusting for binary transfer >bin
Ftp showing directory >dir
Ftp changing directory >cd /<path>/<path>
Ftp getting a file >get <file>
Ftp getting multiple files >mget <filenamecommon>*
Ftp searching for a file >quote site find <filename>
Get the ip number of a computer nslookup <computername>
Check whether another computer is up ping <computername>
Check the pathway to another computer traceroute <computername>
Info about Unix System ::
See who is logged on who ... w ... what
Get the date date
See who logged in lately last -20
See what operating system is there uname -a
See who you are whoami
Get the name of your computer hostname
See the disk space used df -k
See you quota usage quota -v
See how much space all your files need du -k
Mail ::
Check for mail from
Read mail Mail
Compose mail Mail -s <subject> <mailaddress>
Mail a whole file ( one "<" is real ) Mail -s <subject> <mailaddr> < <file>
Compressing Files ::
Compress 50% compress <file>
Uncomress the above file.Z uncompress <file>.Z
Compress 70% gzip <file>
Uncompress the above file.gz gzip -d <file>.gz

Basic UNIX commands


Note: not all of these are actually part of UNIX itself, and you may not find them on all UNIX
machines. But they can all be used on turing in essentially the same way, by typing the
command and hitting return. Note that some of these commands are different on non-Solaris
machines - see SunOS differences.
If you've made a typo, the easiest thing to do is hit CTRL-u to cancel the whole line. But you
can also edit the command line (see the guide to More UNIX).
UNIX is case-sensitive.

Files
 ls --- lists your files
ls -l --- lists your files in 'long format', which contains lots of useful information, e.g. the
exact size of the file, who owns the file and who has the right to look at it, and when it
was last modified.
ls -a --- lists all files, including the ones whose filenames begin in a dot, which you do
not always want to see.
There are many more options, for example to list files by size, by date, recursively etc.
 more filename --- shows the first part of a file, just as much as will fit on one screen. Just
hit the space bar to see more or q to quit. You can use /pattern to search for a pattern.
 emacs filename --- is an editor that lets you create and edit a file. See the emacs page.
 mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a
different directory (see below)
 cp filename1 filename2 --- copies a file
 rm filename --- removes a file. It is wise to use the option rm -i, which will ask you for
confirmation before actually deleting anything. You can make this your default by
making an alias in your .cshrc file.
 diff filename1 filename2 --- compares files, and shows where they differ
 wc filename --- tells you how many lines, words, and characters there are in a file
 chmod options filename --- lets you change the read, write, and execute permissions on
your files. The default is that only you can look at them and change them, but you may
sometimes want to change these permissions. For example, chmod o+r filename will
make the file readable for everyone, and chmod o-r filename will make it unreadable for
others again. Note that for someone to be able to actually look at the file the directories it
is in need to be at least executable. See help protection for more details.
 File Compression
o gzip filename --- compresses files, so that they take up much less space. Usually
text files compress to about half their original size, but it depends very much on
the size of the file and the nature of the contents. There are other tools for this
purpose, too (e.g. compress), but gzip usually gives the highest compression rate.
Gzip produces files with the ending '.gz' appended to the original filename.
o gunzip filename --- uncompresses files compressed by gzip.

o gzcat filename --- lets you look at a gzipped file without actually having to
gunzip it (same as gunzip -c). You can even print it directly, using gzcat
filename | lpr
 printing
o lpr filename --- print. Use the -P option to specify the printer name if you want to
use a printer other than your default printer. For example, if you want to print
double-sided, use 'lpr -Pvalkyr-d', or if you're at CSLI, you may want to use 'lpr
-Pcord115-d'. See 'help printers' for more information about printers and their
locations.
o lpq --- check out the printer queue, e.g. to get the number needed for removal, or
to see how many other files will be printed before yours will come out
o lprm jobnumber --- remove something from the printer queue. You can find the
job number by using lpq. Theoretically you also have to specify a printer name,
but this isn't necessary as long as you use your default printer in the department.
o genscript --- converts plain text files into postscript for printing, and gives you
some options for formatting. Consider making an alias like alias ecop 'genscript
-2 -r \!* | lpr -h -Pvalkyr' to print two pages on one piece of paper.
o dvips filename --- print .dvi files (i.e. files produced by LaTeX). You can use
dviselect to print only selected pages. See the LaTeX page for more information
about how to save paper when printing drafts.

Directories
Directories, like folders on a Macintosh, are used to group files together in a hierarchical
structure.
 mkdir dirname --- make a new directory
 cd dirname --- change directory. You basically 'go' to another directory, and you will see
the files in that directory when you do 'ls'. You always start out in your 'home directory',
and you can get back there by typing 'cd' without arguments. 'cd ..' will get you one level
up from your current position. You don't have to walk along step by step - you can make
big leaps or avoid walking around by specifying pathnames.
 pwd --- tells you where you currently are.

Finding things
 ff --- find files anywhere on the system. This can be extremely useful if you've forgotten
in which directory you put a file, but do remember the name. In fact, if you use ff -p you
don't even need the full name, just the beginning. This can also be useful for finding other
things on the system, e.g. documentation.
 grep string filename(s) --- looks for the string in the files. This can be useful a lot of
purposes, e.g. finding the right file among many, figuring out which is the right version
of something, and even doing serious corpus work. grep comes in several varieties (grep,
egrep, and fgrep) and has a lot of very flexible options. Check out the man pages if this
sounds good to you.

About other people


 w --- tells you who's logged in, and what they're doing. Especially useful: the 'idle' part.
This allows you to see whether they're actually sitting there typing away at their
keyboards right at the moment.
 who --- tells you who's logged on, and where they're coming from. Useful if you're
looking for someone who's actually physically in the same building as you, or in some
other particular location.
 finger username --- gives you lots of information about that user, e.g. when they last
read their mail and whether they're logged in. Often people put other practical
information, such as phone numbers and addresses, in a file called .plan. This
information is also displayed by 'finger'.
 last -1 username --- tells you when the user last logged on and off and from where.
Without any options, last will give you a list of everyone's logins.
 talk username --- lets you have a (typed) conversation with another user
 write username --- lets you exchange one-line messages with another user
 elm --- lets you send e-mail messages to people around the world (and, of course, read
them). It's not the only mailer you can use, but the one we recommend. See the elm page,
and find out about the departmental mailing lists (which you can also find in
/user/linguistics/helpfile).

About your (electronic) self


 whoami --- returns your username. Sounds useless, but isn't. You may need to find out
who it is who forgot to log out somewhere, and make sure *you* have logged out.
 finger & .plan files
of course you can finger yourself, too. That can be useful e.g. as a quick check whether
you got new mail. Try to create a useful .plan file soon. Look at other people's .plan files
for ideas. The file needs to be readable for everyone in order to be visible through 'finger'.
Do 'chmod a+r .plan' if necessary. You should realize that this information is accessible
from anywhere in the world, not just to other people on turing.
 passwd --- lets you change your password, which you should do regularly (at least once a
year). See the LRB guide and/or look at help password.
 ps -u yourusername --- lists your processes. Contains lots of information about them,
including the process ID, which you need if you have to kill a process. Normally, when
you have been kicked out of a dialin session or have otherwise managed to get yourself
disconnected abruptly, this list will contain the processes you need to kill. Those may
include the shell (tcsh or whatever you're using), and anything you were running, for
example emacs or elm. Be careful not to kill your current shell - the one with the number
closer to the one of the ps command you're currently running. But if it happens, don't
panic. Just try again :) If you're using an X-display you may have to kill some X
processes before you can start them again. These will show only when you use ps -efl,
because they're root processes.
 kill PID --- kills (ends) the processes with the ID you gave. This works only for your
own processes, of course. Get the ID by using ps. If the process doesn't 'die' properly, use
the option -9. But attempt without that option first, because it doesn't give the process a
chance to finish possibly important business before dying. You may need to kill
processes for example if your modem connection was interrupted and you didn't get
logged out properly, which sometimes happens.
 quota -v --- show what your disk quota is (i.e. how much space you have to store files),
how much you're actually using, and in case you've exceeded your quota (which you'll be
given an automatic warning about by the system) how much time you have left to sort
them out (by deleting or gzipping some, or moving them to your own computer).
 du filename --- shows the disk usage of the files and directories in filename (without
argument the current directory is used). du -s gives only a total.
 last yourusername --- lists your last logins. Can be a useful memory aid for when you
were where, how long you've been working for, and keeping track of your phonebill if
you're making a non-local phonecall for dialling in.

Connecting to the outside world


 nn --- allows you to read news. It will first let you read the news local to turing, and then
the remote news. If you want to read only the local or remote news, you can use nnl or
nnr, respectively. To learn more about nn type nn, then \tty{:man}, then \tty{=.*},
then \tty{Z}, then hit the space bar to step through the manual. Or look at the man page.
Or check out the hypertext nn FAQ - probably the easiest and most fun way to go.
 rlogin hostname --- lets you connect to a remote host
 telnet hostname --- also lets you connect to a remote host. Use rlogin whenever possible.
 ftp hostname --- lets you download files from a remote host which is set up as an ftp-
server. This is a common method for exchanging academic papers and drafts. If you need
to make a paper of yours available in this way, you can (temporarily) put a copy in
/user/ftp/pub/TMP. For more permanent solutions, ask Emma. The most important
commands within ftp are get for getting files from the remote machine, and put for
putting them there (mget and mput let you specify more than one file at once). Sounds
straightforward, but be sure not to confuse the two, especially when your physical
location doesn't correspond to the direction of the ftp connection you're making. ftp just
overwrites files with the same filename. If you're transferring anything other than ASCII
text, use binary mode.
 lynx --- lets you browse the web from an ordinary terminal. Of course you can see only
the text, not the pictures. You can type any URL as an argument to the G command.
When you're doing this from any Stanford host you can leave out the .stanford.edu part
of the URL when connecting to Stanford URLs. Type H at any time to learn more about
lynx, and Q to exit.

Miscellaneous tools
 webster word --- looks up the word in an electronic version of Webster's dictionary and
returns the definition(s)
 date --- shows the current date and time.
 cal --- shows a calendar of the current month. Use e.g., 'cal 10 1995' to get that for
October 95, or 'cal 1995' to get the whole year.

You can find out more about these commands by looking up their manpages:
man commandname --- shows you the manual page for the command

For further ways of obtaining help, look at the pages with electronic sources of information and
non-electronic sources.

More UNIX Commands


I have noticed that the overwhelming majority of visitors come to this page via a Lycos search. This page
is probably *not* what you're looking for - see the links at the bottom of this page for more useful
information!

 jobs --- lists your currently active jobs (those that you put in the background) and their job
numbers. Useful to determine which one you want to foreground if you have lots of them.
 bg --- background a job after suspending it.

 fg %jobnumber --- foreground a job

 !! --- repeat the previous command (but CTRL-p, is safer, because you have hit return in
addition)

 !pattern --- repeat the last command that starts with pattern

 echo $VARIABLE --- shows the value of an environment variable

 setenv --- lets you set environment variables. For example, if you typed a wrong value for the
TERM variable when logging in, you don't have to log out and start over, but you can just do
setenv TERM vt100 (or whatever). To see what all your environment variables are set to,
type env. The one that you're most likely to have to set is the DISPLAY variable, when using an
X-display.

 unset VAR --- lets you un-set environment variables. Useful, for example, if you've usually set
autologout but want to stay logged on for a while without typing for some reason, or if you
set the DISPLAY variable automatically but want to avoid opening windows for some reason.

 source filename --- you need to source your dotfiles after making changes for them to take
effect (or log off and in again)

 load --- will show you the load average graphically


 ispell filename --- will check the spelling in your file. If you're running it on a LaTeX file use
the -T option to tell it to ignore the LaTeX commands. You can create and use your own
dictionary to avoid having it tell you that your own name, those of fellow linguists, and
linguistics terminology are a typos in every paper you write.

 weblint --- checks the syntax of html files

 latex2html --- translates LaTeX files into HTML

 wn word option --- lets you access the WordNet database and display, for example,
synonyms, hypernyms, or hyponyms, depending on the option you select

Command editing in the tcsh


These things are the same as in emacs:
Backspace --- delete previous character
CTRL-d --- delete next character
CTRL-k --- delete rest of line
CTRL-a --- go to start of line
CTRL-e --- go to end of line
CTRL-b --- go backwards without deleting
CTRL-f --- go forward without deleting

Other useful things


TAB --- complete filename or command up to the point of uniqueness

CTRL-u --- cancel whole line

CTRL-p --- show the last command typed, then the one before that, etc.

(you can also use the cursor up key for this)

CTRL-n --- go forwards in the history of commands

(you can also use the cursor down key for this)

CTRL-c --- cancel the processes after it has started

CTRL-z --- suspend a running process (e.g. in order to do something else in between)

you can then put the process in the background with bg

CTRL-l --- redraws the screen

| (piping) --- Lets you execute any number of commands in a sequence.


The second command will be executed once the first is done, and so forth, using the previous
command's output as input. You can achieve the same effect by putting the output in a file and
giving the filename as an argument to the second command, but that would be much more
complicated, and you'd have to remember to remove all the junkfiles afterwards. Some
examples that show the usefulness of this:
ls | more --- will show you one screenful at a time, which is useful with any command that
will produce a lot of output, e.g. also ps -aux
man ls | grep time --- checks whether the man page for ls has something to say about
listing files by time - very useful when you have a suspicion some command may be capable of
doing what you want, but you aren't sure.
ls -lR | grep dvi --- will show you all your dvi files - useful to solve disk space problems,
since they're large and usually can be deleted.

Some policies on turing

 UNIX Log In and Out Commands.


 UNIX Information Commands.
 UNIX C Language Commands.
 UNIX makefile Commands.
 UNIX Directory Commands.
 UNIX File Commands.
 UNIX Pipe and Redirection Commands.
 UNIX Mail Commands.
 UNIX Control-Key Commands.
 UNIX Terminal Environment Commands.
 UNIX Process Commands.
 UNIX Editor Commands.
 The ex Editor.
 The vi Editor.

UNIX Command Dictionaries


The UNIX manual is mostly on line and the UNIX `man' command is used to display parts of the
manual. Typing

man [command] (CR)

will yield information in an almost readable format during a IBM Telnet session. The problem is
that you have both UNIX and CMS paging the output. You respond to the UNIX paging prompt
`:' with a `(CR)' return for a new page, `d (CR)' for a short new page, u (CR)' for a short page up
(back), or `q (CR)' to quit. For the CMS paging prompt `holding', respond with the designated
`Clear-key'. If you are using IBM Telnet, then `man [command]' usually produces poor output
for the head of the display. The version `man -blou [command] (CR)' should remove
underscoring and other backspacing for printing at UIC, but does not work completely. For a
quick overview of a command try the `-q' quick option:

man -q command] (CR)

Alternatively,

man [command] > [file] (CR)

is useful for redirecting the output to a file that can later be transfer back to CMS for printing
(e.g. by `printdoc'). The UNIX no paging `-r' option does not work in a CMS session, so the
CMS user has to press both the `Return-key' for a new UNIX `man' page or the `Clear-key' for
a new CMS page depending on the odd UNIX prompt or the CMS ``HOLDING'' prompt,
respectively.

This abridged UNIX dictionary is only intended to be a short enough list to get you started
without being bewildered by the enormous UNIX manuals, but with enough commands to be
able to do something useful. For more information use the `man' command or refer to some of
the UNIX texts. UNIX is a trademark of Bell Laboratories.

The format is

[command] [generic operand] : [Definition.]

along with a carriage return `(CR)' for each command. DO NOT FORGET that almost all UNIX
commands must be in lower case. Do not attempt to learn all of this at once, but read some of it
and try it out at an actual computer session.

Return to TABLE OF CONTENTS?

UNIX Log In and Out Commands:

login (CR) : Logon command.


logout (CR) : Logoff command.

Return to TABLE OF CONTENTS?

UNIX Information Commands

man [-option] [command] (CR) : Manual or UNIX help command. The usual quit
sequence `q (CR)' can be used to quit long UNIX `man' listings, `(CR)' is used for new
`man' pages. During a IBM Telnet session the `Clear-key' is needed for new CMS pages
that are not the same as the `man' pages. Otherwise `d', `q' or `Ctrl-c' should work for
UNIX like access.

finger [user] (CR) : Displays system biography on user `[user]'.

whereis [name] (CR) : Locates source for program or command; e.g. `whereis kermit'.

which [name] (CR) : Tell which version of a program or command will be used in your
session in case of multiple copies; e.g. `which cc'.

whatis [command] (CR) : Describes the command [command].

who am i (CR) : Displays current user id and access.

who (CR) : Displays currently logged in users.

Return to TABLE OF CONTENTS?

UNIX C Language Commands

cc -o run [file].c (CR) : Compiles source [file].c, using the standard C compiler `scc2.0'
and producing an executable named run. In place of `cc', use `scc3.0' or `scc' for the latest
version of standard C or `pcc' for portable C.

cc -c [file].c (CR) : Compiles source [file].c, using the standard C compiler `scc2.0' and
producing an object file named [file].o.

cc -hnoopt -o run [file].c (CR) : Compiles source [file].c, using the standard C compiler
`scc3.0' and producing an executable file named run without scalar optimization or vector
optimization while `hopt' enables scalar and vector optimization, Some other
optimization related options are `-hinline' for inlining while `-hnone' is the default no
inlining, `-hnovector' for no vector (vector is the default), and `-h listing' for a pseudo-
assembler (CAL) listing. Some standard C options are `-htask3' for automatic
parallelization (autotasking in crayese) and `-hvector3' for more powerful vector
restructuring. Other `-h' suboptions are `ivdep' for ignore vector dependence, `-
hreport=isvf' generates messages about inlining (i), scalar optimization (s) and vector
optimization (v), and `-hreport=isvf' writes same messages to `[file].v'. A commonly used
form will be

cc -o run -h report=isvf [file].c (CR)

See `man cc' or `docview' for more information.

#define fortran : Form of C header statement to permit the call to a fortran subroutine
from a C program. For example:

#include <stdio.h>
#include <fortran.h>
#define fortran
main()
{
fortran void SUB();
float x = 3.14, y;
SUB(&x, &y);
printf("SUB answer: y = %f for x = %f\n", x, y);
}

#pragma _CRI [directive] : Form of C compiler directive placed within the C code,
where some example directives are `ivdep' for ignoring vector dependence, `novector' for
turning off the default vectorization, `vector' for turning it back on, `inline' for procedure
inline optimization, `shortloop', `noreduction', `getcpus [p]', `relcpus', `parallel ........', and
`end parallel'. See `vector directives' for instance in `docview' for more information and
examples.

Return to TABLE OF CONTENTS?

UNIX makefile Commands

make [-options] [step-name] (CR) : Makes the files [files] according to the template in
the `makefile'. See the examples `makefile *' on the `getdisk hanson' disk in CMS, e.g.,
the file `makefile.unicos_2':

# Use ``make -f make.unicos_2 mrun>& pgm.l &;


run<data>out''.
SOURCES = pgm.f
OBJECTS = pgm.o
FLAGS = -em
mrun : $(OBJECTS)
segldr -o run $(OBJECTS)

.f.o : cft77 $(FLAGS) $*.f


{CAUTION: The commands, like `segldr' or `cft77', must be preceded by a `Tab-key' tab
as a delimiter, but the tab will not be visible in the UNIX listing.}

fmgen -m [make-name] -c cft77 -f [-flag] -o [executable] [source].f (CR) :


Automatically generates a makefile for compiling under the `cft77' compiler and loading
up the executable file named `[executable]'. Invoke with `make -f [make-name]
[executable](CR)' and the execute `[executable]'. Also produces steps for profiling, flow-
traces, performance traces, and clean-up, in the heavily documented makefile. For
example, `make -c cft77 -f -em -o run pgm.f (CR)' produces a makefile named `makefile',
executable named `run', an information listing named `[name in program statement].l'
with loops marked by optimization type, etc.; the making is done with `make run (CR)'.
Caution: the makefile only uses the source name only when that coincides with the name
used in the Fortran `program' statement and only one type of `cft77' flag can be used.
These flaws can be corrected by editing the resulting makefile `[make-name]'.

Return to TABLE OF CONTENTS?

UNIX Directory Commands

mkdir [name] (CR) : Makes a directory or file group name [name]; e.g. `mkdir dirpgm
(CR)' make the directory called `dirpgm'.

pushd [name] (CR) : Pushes from the working directory to the directory [name] keeping
the sequence of directories in a buffer for `popd'.

popd (CR) Pops back up to the prior directory, if `pushd' was used before. For this
reason, `pushd' and `popd' are more useful than the regular change directory command
`cd'.

cd [directory] (CR) : Changes the working directory to the directory [directory]; you can
change it back with `cd(CR)' using your own login id; `cd $HOME (CR)' returns the shell
back to your home directory. `.' denotes the current directory and `..' denotes the root or
parent directory.

cd ~[user] (CR) : Changes working directory to that of login id `[user]'.

cd $TMP (CR) : changes to your temporary directory; same as `cd $TMP (CR)'.

pwd (CR) : Displays working directory; `echo $HOME (CR)' displays the home
directory.

ls [directory] (CR) : displays the contents of the directory `[directory]'.


mv [file1] ... [fileN] [directory] (CR) : moves `[file1]', ..., `[fileN]' to directory
`[directory]'; e.g. `mv addtwo.* diradd' moves all files with prefix `addtwo.' to the
directory `diradd' which must already exist from a prior 'mkdir diradd' command. This
format works for `cp' also.

cp [file1] [directory]/[file2] (CR) : copies [file1] into [file2] in directory [directory]. `cp
[file] . (CR)' copies a file to the current directory using the original name. This format
works for `mv' also.

rmdir (CR) : Removes or erases empty directory. You must first use `rm *' to empty the
file.

Return to TABLE OF CONTENTS?

UNIX File Commands

ls (CR) : Lists sets or files of current user id or current directory.

ls ~[user] (CR) : Lists files or directories under user/account id `[user]'. Also `ls
~/[directory] (CR)' will list the contents of the directory `[directory]' on the same
account.

ls [string].* (CR) : Lists all current files with prefix [name]. Examples of other forms are
`ls *[string] (CR)' or `ls *[string]* (CR)' or `ls *[string1]*[string2]*'.

cat [file1] ... [fileN] (CR) : Lists content of N (N .le. 1) argument files catenated. Use
`cat [file1] ... [fileN] > [fileM] (CR),' to catenate and store the N files in `[fileM]'.

more [file] (CR) : Displays file in half pages of 11 lines; use `q (CR)' for quitting; use
`d' for 11 more lines or `u' to go back up 11 more lines; similarly, `f' and `b' produce full
pages forward and backwards, respectively; while `/[string]?[string]

Caution: works poorly with TELNET from CMS. Use `cat [file] (CR)' with the CMS
Clear-key instead.

cp [file1] [file2] (CR) : Copies file `[file1]' into file `[file2]'.

rm [file1] (CR) : Erases file `[file1]'; can take several file arguments, with the system
asking if you really want to do it, `y' for yes and `n' for no target file `[file2]' already
exists to avoid unintentional. {The query can be removed in any session by the
command `unalias rm (CR)' or permanently by editing the C-shell resource
configuration file `.cshrc'.}
mv [file1] [file2] (CR) : Renames file `[file1'] as file `[file2]', i.e., moves one file to
another.

grep `[str]' [file1] (CR) : Searches for string [str] in file [file1]. ``cat [file1] [file2] |
grep `[string]' (CR)'' searches for the pattern `[string]' in the catenated files. Note
the different string pattern, with the standard single quote used within the command to
enclose the target string when it is more than one word.

diff [file1] [file2] (CR) : Displays the difference between files `[file1]' and `[file2]'.

chmod [mode] [file] (CR) : Changes the read, write and execute permissions for the
file (or files) `[file]' according to the `[mode]' which has form `[[who] [operator]
[permission]]'; `[who]' is `u' for the user, `g' for the defined group', `o' for others
and `a' = `ugo' for all; `[operator]' is `+' to add and `-' for remove; `[permission]' is
`r' for read, `w' for write and `x' for execute; current permissions are displayed with
the default long list command `ls [file] (CR)' in the first field or the sample forms
`drwxrwxr-x' or `-rwxr--r--' with the first character denoting a directory if `d' is
present, a `--' denotes no permission, with each remaining subfield of three denoting
the user, group and others, respectively; for example `chmod go-wx *' removes
write and execute permissions in the current directory for all but the user, `chmod
u+w [file]' adds write permission to only the user; the user may be queried about
removing protection for his own files.

Return to TABLE OF CONTENTS?

UNIX Pipe and Redirection Commands

The commands in this subsection embody some of the powerful advantages of UNIX.

alias [command nickname] `[command definition]' (CR) : Makes alias for


commands to save typing. The quotes around the definition are not required for
single words, but only when the definition contains delimiters like blanks. If used a
lot, put the `alias' in the group account `.cshrc' file and execute by `source .cshrc}.
{`csh' is the UNIX C-shell, one of the UNIX operating sub-systems, and `rc' stands
for resource configuration.}

[command] > [file] (CR) : Redirects standard output of command [command] to file
[file]. E.g., `cat [fn1] [fn2] > [fn3] (CR)', catenating two files into a third file.

[command] > & [file] (CR) : Redirects standard and diagnostic or error output of
[command] to file [file]. E.g., `run > & [output] (CR)', puts compiled listing and
errors into the file pgm.l when pgm.f is compiled.
[command] >> [file] (CR) : Redirects standard output of `[command]' and appends
it to `[file]'. E.g., `run < [data] >> [output] (CR)', catenates the new output with the
current file `[output]'.

[cmd1] | [cmd2] (CR) : Pipes output of command `[cmd1]' to input of command


`[cmd2]'. E.g., `ls -l | grep `Jan 31' (CR)' lists only those files last changed on
January 31. Caution: the string `Jan 31' must be enclosed in single quotes, but the
quotes are optional for single words without delimiters.

[command] & (CR) : Executes `[command]' in the background, so you can work at
something else in your session. E.g., `run < [data] > [output] & (CR)', execute `run'
and stores results into the file `[output]'.

history (CR) : Lists the history of the most recent commands entered.

![number] (CR) : Repeats execution of the command numbered `[number]' in the


`history' listing.

![string] (CR) : Repeats execution of the last command beginning with the pattern
[string] in the `history' listing.

![string]:p (CR) : Repeats listing of the last command beginning with the pattern
`[string]' in the `history' listing, but does not execute it. You can return (CR) to
execute or you can modify it by the command that follows immediately below.

^[str1]^[str2] (CR) : Replaces string `[str1]' with `[str2]' in the previous command
and executes the modified command.

Return to TABLE OF CONTENTS?

UNIX Mail Commands

mail (CR) : Shows user`s mail; use the subcommand `t [N](CR)' to list message
number `[N]' , `s [N] mbox (CR)' to append message `[N]' to your mailbox `mbox'
file or `s [N] [file](CR)' to append `[N]' to another file; `e [N] (CR)' to edit number
[N] or look at a long file with `ex' {see Section on `EX' below}; `v [N] (CR)' to edit
number [N] or look at a long file with `vi'; `d [N] (CR)' deletes {your own mail!}
`[N]'; `m [user] (CR)' permits you to send mail to another account `[user]'; a `~m
[N] (CR)' inside the message after entering a subject, permits you to forward
message `[N]' to `[user]', `\d (CR)' to end the new message {see the send form
below;`x' quits `mail' without deleting {use this when you run into problems}; and
`q (CR)' to quit.
mail [user] (CR) : Sends mail to user `[user]'; the text is entered immediately in the
current blank space; carriage return to enter each line; enter a file with a
`~r[filename] (CR)'; route a copy to user `[userid]' by `~c[userid] (CR)'; enter the
`ex' line editor with `~e (CR)' or `vi' visual editor with `~v (CR)' (see Sections on EX
and on VI) to make changes on entered lines, exiting `ex' with a `wq (CR)' or `vi'
with a `:wq' (CR)'; exit `mail' by entering `\d (CR)'. {A bug in the current version of
Telnet does not allow you to send a copy using the `cc:' entry. However, ending with
the ``hack'' `\d [user_cc] (CR)' should get a copy to user `[user_cc]'.} UNIX users
should not encounter IBM Telnet problems.

mail [userid]@uicvm.cc.uic.edu < [filename] (CR) : Sends the UNIX file `[filename]'
to user `[userid]' at UICVM, i.e., to `[userid]'`s CMS, as with CMS SENDFILE.

mail [name]@[machine].[dept].uic.edu < [filename] (CR) : Sends the UNIX file


`[filename]' to user `[name]' on some UNIX or other machine.

from (CR) : Tells who the mail is from.

Return to TABLE OF CONTENTS?

UNIX Control-Key Commands

Ctrl-h : Erase or backspace over character; note the CTRL-key and h-key must be
simultaneously pressed.

Ctrl-c : Interrupt or break character; stops printing and returns to UNIX.


{Caution: for a IBM TELNET session, should use \c (CR), but this masked interrupt
will not work during long listings due to interference of the CMS `Clear-key' in IBM
Telnet sessions.}

Ctrl-s : Stop character {else or IBM Telnet use ` \s (CR)'}.

Ctrl-q : Quiet character {else for IBM Telnet use `\q (CR)'}.

Ctrl-u : Kill character {else for IBM Telnet use `\u (CR)'}.

Ctrl-w : Word erase character {else for IBM Telnet use `\w (CR)'}.

Return to TABLE OF CONTENTS?

UNIX Terminal Environment Commands


printenv (CR) : Print out environment meta parameters such as defaults, terminal
types and key assignments, eg., SHELL, PATH, TERM, NCPUS, HOME, TMP,
AFS, and AFSTMP.

setenv TERM vt100 (CR) : Sets `TERM' variable to type `vt100', which should be
the default and can be checked by using `printenv', else use `h19b' or your correct
terminal emulation if recognizable by the remote host. The recognizable terminal
type are in the alphabetized subdirectories of `/usr/lib/terminfo', e.g., `v' directory
contains vt100 listings. Caution: `YTERM' is ideal for PC to CMS communication,
but does not have a terminal type that is recognizable by UNIX systems ('vt100' may
sometimes work as a substitute, but `unknown' type means a poor line edit session).

setenv TERMCAP vt100 (CR) : Sets `TERMCAP' variable to type `vt100', else use
`h19b' etc. You can put customized terminal configuration in the file `.termcap' and
enable it with the command `setenv TERMCAP $HOME.termcap' either in your
shell or in your '.login' file.

tset -m :h19b (CR) : Sets terminal type to Heathkit or Zenith type `h19b'.
WARNING: Several terminal commands are given here, because you might have to try
several before you find one that works. Note that one of the biggest problems in
working with advanced, remote computers is COMMUNICATION and that much of
this local guide is intended to solve communication problems.

stty erase \[key](CR) : Set or reset the terminal (`tty') erase key to `[key]'.

stty all (CR) : Display usual Control characters; with arguments can be use to set
terminal communication variables; also try `stty everything'.

Return to TABLE OF CONTENTS?

UNIX Process Commands

jobs - l (CR) : Display a simple single line with currently active job status.

ps (CR) : Display current process ids (``pid'') needed for killing.

ps t[N] (CR) : Displays ``pid'' for terminal or tty [N].

kill -9 [pid] (CR) : Means a ``sure kill'' of ``pid'' [pid]; this becomes necessary when
you lose control of a process or have a session aborted. CAUTION: Aborted sessions
are not uncommon so it is helpful to develop skills of a super process (program) killer.

Return to TABLE OF CONTENTS?


UNIX Editor Commands

ex [file] (CR) : `EX' line editor. This is the preferred editor for LINE EDIT MODE
with TELNET. `:' is the `ex' prompt. `ex [file1] ... [fileN] (CR)' is the form used for
multiple files with the `n' command used to go to the next file, rather than `q' to
quit. Ex can also be used in vi with ':' as a prefix, when vi works. `ed' is another line
editor with less availability. More details on `ex' are given in the next section.

vi [file] (CR) : Invokes the UNIX full screen editor `vi' to edit file [file]; this visual
editor has a large set of subcommands. Warning: the `vi' command will NOT work
properly with the LINE MODE of CMS TELNET and YOU WILL LIKELY GET IN A
STUCK SESSION IF YOU TRY IT. (Try to get access to a UNIX system or PC
Telnet systems, such as those in the 2249f SEL PC Lab.)

vi -r [file] (CR) : Form of `vi' used to recover `[file]' after aborted session. Similarly,
`ex -r [file] (CR)' is for an aborted `ex' session.

view [file] (CR) : This is the read only form of `vi'.

Return to TABLE OF CONTENTS?

ex Editor
`Ex' is the UNIX line editor (`ed' is another UNIX line editor) and `vi' is the full screen
editor that is disabled by IBM TELNET. The prompt is `:', but the user enters input at the
bottom of the screen with IBM TELNET line mode. In `ex' `.' means the current line, `$'
means the last line, and `%' means the whole range of lines `1,$'. `[L1],[L2]' denotes the
range from line `[L1]' to line `[L2]'. The user may want to do major editing on the CMS
multi-line editor XEDIT and send the file using the FTP file transfer protocol. Some
students may have had experience with this editor (or the similar `ed' editor) from EECS
courses. These `ex' commands can be used within the `vi' editor by typing a colon `:' in
front of the `ex' command, which is another reason for learning `ex' with `vi' when you
have an account where `vi' can be used.

0a (CR) : This form of the append subcommand puts you in input mode starting
with line 1, new lines are entered following a `(CR)', and input mode is ended with a
solitary or sole `.' on a line with an immediate `(CR)', i.e., `.(CR)'. This is not the
usual method for opening a new file, but the usual way does not work correctly with
the IBM Telnet and CMS pass through.

q! (CR) : Quit or abort `ex' without saving. Use, especially, in an emergency when
your edit session seems hopeless, and you want to start over at the beginning.
w [file] (CR) : Save (write) or resave into the new file [file], but do not end. If no
[file] is specified, then the current file is resaved.

w! [file] (CR) : Resave (rewrite) into an old file [file], but do not end. `Ex' will not
write over an existing non-current file with the `w' command without the `!'.

wq (CR) : Save and quit ex.

w|n (CR) : When `ex' is used on more than one file, writes the current file and
makes `ex' go to the next file. `|' puts two `ex' commands together.

nu (CR) : Number current line.

set number (CR) : Number all lines; line numbers are needed for effective use or
`ex'; by putting this and other commands in your `.exrc' Ex Resource Configuration
file, the command will be operative until it is changed.

set list (CR) : Show carriage control characters, such as End-Of-Line ($ = EOL).

/[string] (CR) : Search forward for pattern [string].

?[string] (CR) : Search backward for pattern [string].

[L1],[L2] p (CR) or [L1],[L2] l (CR) : Prints or lists (listing control characters) lines
[L1] to [L2]. `% (CR)' lists the whole range of lines, and `.,$ (CR)' lists the current
line to the last line.

$ (CR) : Prints last line.

\d (CR) : Scrolls lines {In UNIX, use `Ctrl-d'}.

[L1],[L1]+[N] p (CR) : Prints lines [L1] to [L1]+[N].

[L1],[L2] d (CR) : Deletes lines [L1] to [L2].

[L1] i (CR) : Insert at line [L1]. End with a lone `.(CR)' after the last input line.
Does not work on an empty file.

[L1] a (CR) : Append after line [L1]. End with a lone `.(CR)' after the last input
line. Does not work on an empty file.

[L1] o (CR) : The UNIX open command does not work correctly with IBM
TELNET because the usual end commands do not work properly. End with a line `.
(CR)'.

[L1] c (CR) : Change line [L1]; end with `.(CR) alone.


[L1],[L2] co [L3] (CR) : Copy lines [L1] to [L2] to after line [L3].

[L1],[L2] m [L3] (CR) : Move lines [L1] to [L2] to after line [L3].

[L1],[L2] t [L3] (CR) : Take {copy} lines [L1] to [L2] to [L3]; destination [L3] can
not be in ([L1] to [L2]-1).

[L1],[L2] g/[string]/[commands] (CR) : Globally search for all occurrences of


pattern [string] in lines [L1] to [L2] (or current line only if no lines are given), and
execute commands [commands] on matching lines.

[L1],[L2] s/[string1]/[string2]/g (CR) : Substitute [string2] for all [string1] in lines


[L1] to [L2] (or current line only if no lines are given). If `gp' is used in place of `g'
then print change(s).

[L1],[L2] & (CR) : Repeat prior substitution command.

g/[string1]/s/{/}[string2]/gp (CR) : Globally substitute [string2] for each [string1] in


all lines and print changes; works globally; use `?' in place of `/' if [string*] contains
a `/'.

[L] r [file] (CR) : Read in or append file [file] at line [L].

u (CR) : Undo most recent substitution.

[L1],[L2] ya [buffer] (CR) : Yank lines [L1] to [L2] to named buffer [buffer]. See
`pu'.

[L1],[L2] d [buffer] (CR) : Delete and yank lines [L1] to [L2] to named buffer
[buffer]. See `pu'.

[L3] pu [buffer] (CR) : Put lines from named buffer [buffer] after line [L3]. See `ya'.

g/^$/d (CR) : Delete all null lines.

s/A\/B/A\/C/g (CR) : Illustrates the use of `\' to change a string containing the `/'
delimiter to change `A/B' to `A/C' globally.

Return to TABLE OF CONTENTS?

vi Editor
The UNIX full screen editor `vi' is a tightly designed editing system in which almost every
letter has a function and the function is stronger for upper than lower case. However, a
letter and its actual function are usually closely related. It is important to remember that
the `(Esc)' escape key ends most functions and a `(Esc), (Esc)' double application certainly
ends the function with the ring of a bell. The subcommand `u' undoes the last function
(presumably an error). Use `:q! (CR)' to end with out saving, especially in hopeless
situations. Use `:wq (CR)' to resave and end {`ZZ' also resaves and ends, but will not
resave if the file has been saved in another file and no further changes have been made}, or
`:w (CR)' to only resave. The character `:' prompts the UNIX line editor `ex' which you can
think of as being embedded in `vi'. Some of the above critical `vi' subcommands are
repeated below with others. Most `vi' subcommands are not displayed when used and do
not take a carriage return `(CR)'. The fact that most keys have a meaning both as single
characters and as concatenations of several characters has many benefits, but has
disadvantages in that mistakes can turn out to be catastrophic. {Remember that `(Esc),
(Esc), u' key sequence!} {WARNING: `VI' is disabled during an IBM Telnet session.}

(Esc) : End a command; especially used with insert `i', append `a' or replace 'R'.

(Esc), (Esc) : Ensured end of a command with bell; press the Escape-key twice; use
it.

u : Undoes last command; usually used after `(Esc)' or `(Esc), (Esc)'; if undoing is
worse then repeat `u' again to undo the undoing.

:set all (CR) : Display all vi options. Use this ex command when your initial vi
session is poor. Customized options are placed in the `.exrc' ex resource
configuration profile.

:w (CR) : Save or resave the default file being edited, but do not end.

:w [file] (CR) : Save into a new file [file], but do not end.

:w! [file] (CR) : Save or resave into an existing file [file], but do not end.

:q (CR) : Quit vi without saving, provided no changes have been made since the last
save.

:q! (CR) : Quit vi without saving, living the file as it was in the last save.

:wq (CR) : Save the default file being edited, and quit.

ZZ : Save the edited file, provided not changes have been made since the last save of
the edited file to any file, and quit `vi'. {Warning: if you just saved the edited file into
any other file, the file will NOT be resaved. `:wq (CR) is much safer to use.}

h or j or k or l : The arrow keys, such that

k = up
^
|
h = left <-- --> right = l
|
v
j = down
each take a number prefix that moves the cursor that many times.

(CR) : moves cursor a line forward; `+' also does.

-- : Moves cursor a line backward.

[N] (CR) : Moves cursor [N] lines forwards.

[N]-- : Moves cursor [N] lines backwards.

Ctrl-f : Moves cursor a page forward.

Ctrl-b : Moves cursor a page backward.

Ctrl-d : Moves cursor a half page down.

Ctrl-u : Moves cursor a half page up.

[L]G : Go to line [L]. `1G' moves the cursor to the beginning of the file (BOF).

G : Go to the last line just before the end of file (EOF) mark. `$G' does the same
thing.

0 : Go to beginning of the line (BOL).

^ : Go to beginning of the nonblank part of the line (BOL).

~ : Got to first nonblank character on a line.

$ : Go to end of the line (EOL).

[N]| : Go to column [N] of the current line.

% : Find the matching parenthesis.

/[string] (CR) : Find the next occurrence of `[string]' forwards. Use `n' to repeat, or
`N' to search backwards.

?[string] (CR) : Find the next occurrence of` [string]' backwards.


n : Repeat last `/[string] (CR)' or `?[string] (CR)'; think of the file as being wrapped
around from end to beginning, so that when you return to the start you know that
you have found all occurrences.

N : Repeat last `/[string] (CR)' or `?[string] (CR)', but in reverse.

. : Repeat last change. This is best used along with the repeat search `n' or `N'.

i[string](Esc) : Insert a string `[string]' before current character at the cursor; the
subcommand `i' itself and other subcommands are not displayed; a `(CR)' in the
string during the insert is used to continue input on additional lines; end with the
escape key `(Esc)' or `(Esc), (Esc)'.

o[string](Esc) : Opens a new line below the current line for insertion of string
`[string]'; end with `(Esc)' or `(Esc), (Esc)'; use for POWER TYPING input for an
old or new file; `O[string](Esc)' opens a new line above the current line for
insertion.

I[string](Esc) : Insert a string at the beginning of the current line (BOL), else is like
insert `i';a `(CR)' in the string during the insert is used to continue input on
additional lines; end with `(Esc)' or `(Esc), (Esc)'.

J : Joins next line to current line.

a[string](Esc) : Appends a string `[string]' following the current character at the


cursor, else it works like insert `i'; use `(CR)' in the string to continue input onto
new lines; end with `(Esc)'; also use for POWER TYPING.

A[string](Esc) : Appends a string `[string]' at the end of a line (EOL), works like `i'
or `a'; use `(CR)' in the string to continue input onto new lines; end with `(Esc)';
also use for POWER TYPING.

r[C](SPACE) : Replace a single character over the cursor by the single character
[C]; finalize with the Space-bar.

R[string](Esc) : Replace a string of characters by `[string]' in until `(Esc)' is typed to


end.

s[string](Esc) : Substitutes the string `[string]' for the single character at the cursor.
The multiple form `[N]s[string](Esc)' substitutes `[string]' for the `[N]' characters
starting at the cursor.

x : Delete the current character at the cursor.

d(SPACE) : Deletes a single character. `[N]d(SPACE)' deletes `[N]' characters.


dd : Deletes the current line. `[N]dd' deletes `[N]' lines.

D : Deletes from the cursor to the end of line (EOL).

dw : Deletes the current word; `[N]dw' deletes `[N]' words.

w : Move cursor to the beginning of the next word. `[N]w' moves the cursor `[N]'
words forward. `[N]b' moves it `[N]' words backward. `[N]e' moves it to the end of
the word.

[N]y(SPACE) : Yanks `[N]' characters starting at the cursor and puts them into the
default buffer. `[N]yy' yanks `[N]' lines.

p : Puts the current contents of the default buffer after the cursor if characters or
after the current line if lines. Helpful to use right after a character yank `y' or a
character delete `d' or a line yank `yy' or a line delete `dd', along with a search
`/[string](CR)' or repeat search `n'. and a repeat change `.'. `P' puts the contents of
the default buffer before the current line.

"b[N]Y : Yank [N] lines starting with the current line to the buffer labeled b; the
double quote {"} is used to avoid an id conflict with subcommand names; any letter
other than `x' can be used to name the buffer; safer than the line yank `yy' because
it is very easy to accidentally change the default buffer.

"b[N]dd : Deletes [N] lines starting with the current line to the buffer labeled `b'.

"bp : Put back lines from the buffer labeled `b' after or below the cursor; use after a
yank or delete to a labeled buffer to move groups of lines from one location to
another.

"bP : Put back lines from the buffer labeled `b' before or above the cursor; use after
a yank or delete to a labeled buffer to move groups of lines from one location to
another.

Some `ex' editor commands that are useful in `vi' follow the `:' prompt. See the previous
section on `ex' for more commands.

:nu (CR) : Number current line.

:[L1],[L2] d (CR) : Deletes lines `[L1]' to `[L2]'.

:[L1],[L2] m [L3] (CR) : Move lines `[L1]' to `[L2]' to after line `[L3]'.

:[L1],[L2] t [L3] (CR) : Take [copy] lines `[L1]' to `[L2]` to `[L3]'; destination `[L3]'
can not be in `[L1]' to `[L2]-1'.
:[L1],[L2]s/[string1]/[string2]/g (CR) : Substitute `[string2]' for all `[string1]' in
lines `[L1]' to `[L2]' only.

:s/[string1]/[string2]/gp (CR) : Substitute `[string2]' for all `[string1]' in current line


only and print change(s).

:g/[string1]/s/{/}[string2]/gp (CR) : Globally substitute `[string2]' for each `[string1]'


in all lines and print changes; works globally; use `?' in place of `/' if `[string*]'
contains a `/'.

:[L]r [file] (CR) : Append file [file] at line `[L]'.

También podría gustarte