____________________________________________________________________________
Gerard J. Kleywegt
Department of Molecular Biology
University of Uppsala
Uppsala - Sweden
With help from Alwyn Jones, Erling Wikman and Arnold Andersson
1
Unix for Beginners
____________________________________________________________________________
I - Table of contents
Chapter/Section Item Page
_________________________________________________________________
I Table of contents 2
II Introduction 4
II-1 Literature 4
II-2 What is UNIX ? 4
II-3 About this guide 5
III UNIX versus VMS 6
III-1 Commands 6
III-2 Miscellaneous 7
IV Basic concepts 8
IV-1 Logging in 8
IV-2 Commands 8
IV-3 Getting help 8
IV-4 Control characters 8
IV-5 Editors 9
IV-6 I/O streams 9
IV-7 File system 9
IV-8 Pathnames 10
IV-9 Listing directory contents 10
IV-10 Meta-characters 10
IV-11 Simple file manipulation 11
IV-12 Linking files 11
IV-13 Changing file permissions 12
IV-14 Manipulating text files 12
IV-15 I/O redirection 13
IV-16 History facility 13
IV-17 Aliases 14
IV-18 Job control 14
V Example files 16
V-1 .login 16
V-2 .cshrc 16
V-3 Other files 17
VI Example scripts 18
VI-1 compressor 18
VI-2 split 18
VI-3 repeat 19
VI-4 police 19
VI-5 forall 19
VI-6 sln 20
VI-7 dirtar 21
VI-8 tardir 21
2
Unix for Beginners
____________________________________________________________________________
VII Miscellaneous 22
VII-1 ftp 22
VII-2 rlogin/telnet 22
VII-3 make 22
VII-4 tar 22
VII-5 more commands 22
VII-6 Files versus processes 23
VII-7 sed 24
VII-8 sed 24
VII-9 X-windows programs 24
VII-10 cut 24
VII-11 system-dependent Fortran functions and subroutines 24
VII-12 command-line arguments in Fortran 25
VII-13 dynamic memory allocation in Fortran 25
VII-14 saving disk space 25
VII-15 units 25
VII-16 w and who 25
VII-17 factor 26
VII-18 some more commands 26
VIII Index of Unix commands 27
IX Inverted index of Unix commands 30
3
Unix for Beginners
____________________________________________________________________________
II - Introduction
II-1 • Literature:
- S.G. Kochan & P.H. Wood, “UNIX Shell Programming”, Hayden Book Company,
Berkeley, 1985 (usually found in the Patterson room);
- G. Anderson & P. Anderson, “The UNIX C Shell Field Guide”, Prentice-Hall, Englewood
Cliffs, 1986 (in Erling’s room);
- P.E. Bourne, “UNIX for VMS Users”, Digital Press, 1990 (in Alwyn’s room);
- “CONVEX UNIX for the Beginning User - Training Course”, CONVEX Computer
Corporation, 1988 (available on request from Gerard);
- “CONVEX UNIX for the Advanced User - Training Course”, CONVEX Computer
Corporation, 1988 (available on request from Gerard).
4
Unix for Beginners
____________________________________________________________________________
II-3 • About this guide.
This guide attempts both to help novice UNIX users to get started and to help more
experienced users to get more out of their operating system. It has been written by a
reasonably spoiled SGI/IRIX/C-shell user. This means that not all commands and scripts are
necessarily identical or even available if you use other machines ! Novice users who have
used VAX-VMS will be interested in chapter III; more experienced users will probably want to
skip sections III and IV.
Just about every computer on the market today runs Unix, except the Mac (and nobody
cares about it).
Bill Joy
Making files is easy under the UNIX operating system. Therefore, users tend to create
numerous files using large amounts of file space. It has been said that the only standard
thing about all UNIX systems is the message-of-the-day telling users to clean up their files.
System V.2 administrator's guide
5
Unix for Beginners
____________________________________________________________________________
III - UNIX versus VMS
III-1 • Commands:
The following is a list of common VAX/VMS commands and their UNIX counterparts. Use
the manual pages for more information regarding the precise syntax, options etc.
____________________________________________________________________________
VMS command UNIX command description
____________________________________________________________________________
show default pwd show current directory
show system ps show current processes
show users who OR finger show current users
show symbol * alias show symbols/aliases
show dev d df show file system
sh queue * at -l show batch queues
show process ps show my processes
____________________________________________________________________________
set def sys$login cd go to home directory
set def [-] cd .. go to parent directory
____________________________________________________________________________
create/dir [.mydir] mkdir mydir create new directory
del my.dir; rmdir mydir delete directory
copy cp copy
delete rm delete file(s)
delete/confirm rm -i delete after confirmation
dir/size=all/date/prot ls -FartCos extended directory listing
dir [...] ls -R list directory tree
dir/size/total du disk usage
rename f_1 f_2 mv f_1 f_2 rename/move a file/dir.
purge --------------- delete older versions
set protection chmod change file protection
---------------------- chown change ownership
____________________________________________________________________________
append a b cat a >> b append file a to file b
diff a b diff a b list differences
search a "str" grep str a find "str" in file(s)
edit vi OR jot OR emacs OR .. edit
type cat list file contents
type/page more OR less list file(s) in portions
____________________________________________________________________________
6
Unix for Beginners
____________________________________________________________________________
____________________________________________________________________________
VMS command UNIX command description
____________________________________________________________________________
fortran file.for f77 -c file.f compile file
link file.obj f77 -o X file.o link
run file file execute program
@file source file execute command script
spawn cmd cmd & spawn a command
submit at OR batch submit a job
a:=cmd alias a cmd define symbol/alias
write sys$output echo write to output device
____________________________________________________________________________
recall/all history show recent commands
recall cmd !cmd execute previous cmd
---------------------- set history=100 remember last 100 commands
help cmd man cmd give help about cmd
phone talk exchange messages
mail mail OR Mail electronic mail
show terminal stty show terminal settings
set terminal stty set terminal characteristics
backup tar backup file(s)
____________________________________________________________________________
III-2 • Miscellaneous:
One of the most important differences between VMS and UNIX is that UNIX does not allow
for different versions of the same file (e.g., on the VAX you may have login.com;1,
login.com;2 etc.). This means that you never have to purge your directories, but also that you
overwrite a file if you send output to it more than once !
Under VMS you usually have a file LOGIN.COM in your home directory which is
executed when you log on to the VAX; under UNIX, these are replaced by .login (executed
when you log in) and .cshrc (executed whenever you start a C-shell process).
File names under UNIX are also different; for instance, a file which is called
DISK5:[USER.XPLOR]XPLOR.INP;35 on the VAX might be called
/disk5/user/xplor/xplor.inp on a UNIX system.
Another major difference is the case-sensitivity of UNIX, in other words: three files
called text.dat, TexT.Dat and TEXT.DAT refer to the same file under VMS but to different
files under UNIX !
7
Unix for Beginners
____________________________________________________________________________
IV - Basic concepts
IV-1 • Logging in:
In order to be able to use a computer, you have to log in. For this you need a user name, a
password and a home directory (all three are provided by the system manager the first time).
Your user name should not contain special characters (such as “/” or “-”) and be
unique. Your password should be long and hard to guess (i.e., don’t use your own name, your
cat’s name, your phone number, etc.). Change your password regularly (use the command
passwd)! Passwords are to be taken extremely seriously ! If anyone obtains a valid
username/password combination, he or she can log on to the system and do a lot of damage
(deleting your files, for example, or installing virus programs) !!!
The system file /etc/passwd contains a list of all authorised users with their (encrypted)
passwords, user id, group id, home directory and default shell-type. If you cat (type the
contents of) this file, you will notice that there are several “special” users, for example, “root”
(system manager), “demo” and “ftp”.
IV-2 • Commands:
Commands tell the system what to do. Under UNIX they usually consist of lower-case letters.
The general syntax is: command [option(s)] [argument(s)]. The arguments are usually files
(sometimes other devices, such as a display window or a printer) upon which the command
will act. The options modify the way a command works; often they are single letters preceded
by a dash (“-”; minus sign); usually several options can be combined and prefixed by a single
dash. Please note that some commands mix options and arguments, some use a “+” instead of
a “-” or even nothing at all. Also note that sometimes you have to provide “obvious”
arguments; for instance, the find command, which looks for specific files in a directory tree,
needs the -print option if you want to see the results on your screen ...
You may type several commands in a row, provided you separate them with semi-
colons (“;”). If you need to continue a command on the next line, use the backslash character
(“\”) at the end of the first line, etc.
8
Unix for Beginners
____________________________________________________________________________
- CTRL-q to resume output
- CTRL-o to discard output to the terminal
- CTRL-z to suspend the current process (type fg, for “foreground” to resume it)
- CTRL-c to kill the current process
- CTRL-d to log out
IV-5 • Editors:
There are four types of editors under UNIX:
(1) line editors (obsolete): ed, ex
(2) full-screen editors (soon obsolete ?): vi, emacs
(3) window-based editors (Macintosh-like): jot, zip, xedit
(4) stream editors (will edit files for you using a command script): awk, sed
Note that jot and zip only run on SGIs; xedit is available on most machines running X-
windows; emacs is not available on all machines; sed and awk are very powerful tools (they
make a lot of “jiffy” programs obsolete) !
IV-8 • Pathnames:
9
Unix for Beginners
____________________________________________________________________________
The complete name of a directory (or file) is called its pathname. To see the complete
pathname of your current directory, use pwd (print working directory); this will display for
example: /nfs/taj/bubba if your username is “bubba” and you work in Alwyn’s group. A
pathname which begins with a slash (i.e., one which is defined starting in the root directory) is
called an absolute pathname. You may also use relative pathnames; they are given relative to
your current directory. For example, a file “xplor.inp” in Bubba’s subdirectory “xplor” may be
referred to as xplor/xplor.inp when Bubba is in his home directory. Another user in his home
directory on the same disk might use: ../bubba/xplor/xplor.inp (the “..” refers to the parent
directory) and users on other disks might use either /nfs/taj/bubba/xplor/xplor.inp or
~bubba/xplor/xplor.inp; the “~bubba” means: Bubba’s home directory. Bubba himself could
also use ~/xplor/xplor.inp (a single “~” refers to one’s own home directory).
Filenames may contain up to 256 characters; they are case-sensitive, so “test” and
“TEST” are two different files ! Try to avoid special characters (such as: / \ | ‘ “ ? $ # ; ~ - ! @
% & etc.), except for periods and underscores.
IV-10 • Meta-characters:
You may use several meta-characters (wildcards) in filenames:
(1) “*” - matches any number of characters; e.g., ls */*.f will list all Fortran source files in the
current directory and all of its sub-directories.
(2) “?” - matches any single character; e.g., ls file?.f will list file0.f, file1.f, file2.f etc., but not
file10.f, filexyz.f and so on.
(3) “[]” - within the brackets you may put a list of ASCII characters which are considered to
match, or a range of characters separated by a dash; e.g., ls file[135].f will list file1.f, file3.f
and file5.f, but not file2.f etc.; ls [A-Z1-4]*.f will list all Fortran files whose name begin either
with an uppercase letter or with 1, 2, 3 or 4.
These meta-characters may be used with nearly all UNIX commands, not just with ls !
10
Unix for Beginners
____________________________________________________________________________
11
Unix for Beginners
____________________________________________________________________________
File permissions (read, write, execute permission) can be altered with the chmod command.
This can be used in two different ways. The easiest one has the syntax: chmod who operator
permission filename(s), where:
- who = u (user), g (group), o (others) or a (all three classes)
- operator = + (add), - (remove) or = (assign permission(s))
- permission = r (read) and/or w (write) and/or x (execute)
Examples: chmod g=rx file1, chmod a+x file2, chmod o-wx file3 etc.
The second syntax involves octal protection indicators: chmod permission_bits
filename(s). The “permission_bits” is a set of three digits between 0 and 7, one for u, g and o.
Read permission has been assigned the value 4, write permission 2, execute permission 1 and
no permission 0; the appropriate permission_bits are found by adding the values of the granted
permissions, for example: chmod 755 xplor.exe will give the owner rwx-permission
(4+2+1=7) and all other users rx-permission (4+1=5).
Note that directories are only accessible if you have read and execute permission; the
same is true for script files and program executables. Also note that you may prevent a file
from being overwritten or deleted by giving yourself no write permission. If you want to
change the ownership of a file, use the chown command.
12
Unix for Beginners
____________________________________________________________________________
IV-15 • I/O redirection:
Often it is handy to redirect the output of a command or program to a file (or a printer or ...).
The syntax to do this is: command > outfile. This will overwrite “outfile” if it existed
already, unless you put the statement noclobber in your .cshrc file (then you may only
overwrite files by using “>!” instead of “>”). If you want to append the output to an existing
file, use “>>”. Example: to append file2 to file 1, use: cat file2 >> file1. If you also want to
redirect the standard error output to the same file, use “>&” or “>>&”.
To redirect standard input from a file, use: command < inputfile, for instance: xplor <
xplor.inp. Alternatively, you may use “<< string” to indicate that everything that follows on
standard input until the line which contains only “string” is to be used as input. For example:
4d_ono crap.o << end-of-input
yes (use display)
@lsq.omacro
stop
end-of-input
Of course, you may use combinations of input and output redirection: xplor <
trafun.com >>& all_trans.out and so on.
Another way of I/O redirection is the use of “pipes”: a pipe causes the standard output
of one command to be transferred into the standard input of another command. The syntax is:
command1 | command2; for example, to find out how many users are logged in, type who |
wc -l; to get a sorted list of logged in users, type who | sort, or who | sort | more. A more
useful example: to count the number of amino acids in a PDB file, use: grep “ CA “ file.pdb
| wc -l; to list the CA-atoms of all alanyl residues, use: grep ALA file.pdb | grep “ CA “. If
you also want to pipe the standard error output, use “|&” instead of “|”.
13
Unix for Beginners
____________________________________________________________________________
You type: What is executed:
!5 ls -al file1 file2 file3
more !5:2-3 more file2 file3
cat !5:$ cat file3
more !5^ more file1
lpr !5:2 lpr file2
lpr !5* lpr file1 file2 file3
You may also modify previous commands, for example: !!:s^old^new; if the previous
command was ls -l *.old, the new command will be ls -l *.new. To verify that the edited
command is correct, type :p immediately after the event identifier: !!:p:s^old^new; if it is
correct, type !! to execute it.
IV-17 • Aliases:
The csh-command alias lists all defined aliases. The command also allows you to rename or
abbreviate commands, for example: alias rm ‘rm -i’ will mean that every time you type rm
you actually execute rm -i. Should you at some stage want to use the original rm command
without the -i option, then you have the following options: unalias rm removes the alias,
/bin/rm executes the rm program itself without any option, \rm does the same.
An alias may contain more than one command, for example: alias status ‘date ; who |
sort’.
If you want to create aliases for commands which require an argument (usually, a
filename), use \!* (there is actually some perverted logic behind this ...) at the position of the
argument: alias ala ‘grep ALA \!* | grep CA | wc -l’; now if you type ala file.pdb the result
will be the number of alanyl residues in that file.
14
Unix for Beginners
____________________________________________________________________________
To get information about your (and other people’s) processes, use the ps command (for
example, if you want to know if anybody else is already running XPLOR on an SGI before
submitting your own XPLOR job, type: ps -ef | grep -i xplor).
The kill command can also be used to terminate or interrupt processes by referring to
their PID (process id; these are listed by the ps command), for example: kill -9 1734, kill -
STOP 182, kill -CONT 182, etc.
If you start a job in the background and you plan to log out before it is finished, submit
it with the nohup command (no hang-up): nohup xplor.com &; if you don’t do this, all your
processes, including your XPLOR job, will be killed when you log out !
Use nice and renice to run background jobs with lower priority (so your big
calculations are not in the way of interactive users).
15
Unix for Beginners
____________________________________________________________________________
V - Example files
V-1 • .login:
I recommend that you keep it to an absolute minimum. I prefer to keep all my settings in the
.cshrc file.
umask 022
eval `tset -s -Q`
stty line 1 erase '^H' kill '^U' intr '^C' echoe
V-2 • .cshrc:
The following are fragments of my .cshrc file; note that this particular one is tailored to SGI’s
IRIX.
#
set path = (. .. ~ ~/bin /usr/bsd /bin /usr/bin /usr/bin/X11 /usr/sbin
/usr/demos /usr/demos/bin /usr/etc /usr/local/bin /usr/bin/dn /usr/ucb
/nfs/taj/alwyn/o/bin /usr/people/alwyn/a/bin /nfs/vega/people/alwyn/a/bin
/nfs/public/IRIX/bin /usr/new /user/bin /user2/bin)
limit coredumpsize 0
source /nfs/public/IRIX/ccp4/include/ccp4.setup >& /dev/null
set autologout=240
set ignoreeof
set history=100
set savehist=250
set filec
set fignore = (.o .a .old .f.old .f.older .f.oldest)
set notify
set time=5
set prompt = " > "
alias newsh 'wsh -s40x80 -f Screen.15 -t"new shell"'
alias ftp 'ftp -i'
alias diff 'diff -lsbwit'
alias comp 'compress -v'
alias unco 'uncompress -v'
alias note 'cat ~/stuff/notes | grep \!*'
alias down 'cd \!*'
alias up 'cd ../'
alias left 'cd ../\!* '
alias home 'cd'
alias dir ls
alias dsd 'ls -laF \!* | sort'
alias dsds 'ls \!* | grep "`date | cut -c5-10`"'
alias ls '\ls -FartCos'
alias l '\ls -Cal'
alias lc '\ls -C'
alias lss '\ls -FartCos \!* | sort'
alias fint 'find * -print | grep \!*'
alias sus 'who -a'
alias sss 'ps -ef | sort'
alias time '/bin/time'
alias h 'history'
alias h5 'history | tail -5'
alias hg 'history | grep \!*'
alias hg5 'history | grep \!* | tail -5'
alias grep 'grep -i'
16
Unix for Beginners
____________________________________________________________________________
alias count 'grep -c'
alias help man
alias ta 'tail -100'
alias he 'head -100'
alias lo logout
alias du 'du -rk'
alias grand '\du -sk *'
alias df 'df -k'
alias s source
alias rm 'rm -i'
alias dorm '\rm'
alias del 'rm'
# disp alien will set the environment variable DISPLAY to alien.bmc.uu.se
alias disp 'set x=\!* ;setenv DISPLAY $x.bmc.uu.se:0;setenv|grep -i display'
# a quick way to set your terminal to VT100
alias vt100 'setenv TERM vt100 ; setenv | grep -i term'
# Fortran compilation for SGI, ESV, ALPHA/OSF1
alias f77sgi '/bin/time f77 -Olimit 3000 -v -check_bounds -u -w0 -c'
alias f77esv '/bin/time f77 -Olimit 3000 -v -check_bounds -u -c'
alias f77al '/bin/time f77 -Olimit 3000 -C -O -u -v -c'
# head AND tail a file
alias ht 'set x=\!* ; echo head $x ; head $x ;echo tail $x ; tail $x'
alias xterm 'xterm -sb'
alias show 'ps -ef | grep $user | grep -i \!*'
17
Unix for Beginners
____________________________________________________________________________
VI - Example scripts
The following script files can be copied from /nfs/public/shell. For more information on shell-
specific constructs (if, while, foreach, -e, -f, $#argv etc.), consult the manual pages for the csh
command.
VI-1 • compressor:
This script can be used to automatically find and compress large map files (or it can easily be
changed to find and act on other files). Consult the manual pages of the find command for an
explanation of all possible options.
VI-2 • split:
This script will, in a given directory, copy all Fortran files (.f) to a subdirectory called fsplit
(must exist), do an fsplit and remove the original sources (beware of filename duplications !).
Note the uses of the set command.
18
Unix for Beginners
____________________________________________________________________________
VI-3 • repeat:
This script will execute a given command repeatedly at regular time intervals (using the sleep
command).
VI-4 • police:
This script will check every ten minutes whether there are processes which have consumed
more than 60 minutes of CPU-time and still do not have the highest nice-value; if there are any
(and if they’re not owned by root), they will be reniced. This version of the script can only be
executed by root.
VI-5 • forall:
Some UNIX commands (such as tail and lpr) do not allow for wildcards in the filename
specifications. In order to circumvent this problem, the following script takes a file description
containing multiple arguments or wildcards and a command and will execute the command for
each of the files. Examples: forall '*.f' tail -20 and forall '*.ps' lpr -Pqms.
19
Unix for Beginners
____________________________________________________________________________
echo
echo "usage: forall file_id command [arg1 ... arg6]"
echo
exit 1
endif
set sour=$1
set comm="$2 $3 $4 $5 $6 $7 $8"
echo "===> FORALL (" $sour ") DO " $comm
foreach file ($sour)
echo $comm $file
$comm $file
end
echo "Done ..."
exit 0
VI-6 • sln:
This script is a safe soft-linker. In order to prevent you from accidentally erasing files by
swapping the arguments to ln -s, it checks if the first file actually exists. If you put this script
in your private /bin directory, you should put the following in your .cshrc file: alias ln 'echo
USE ~/bin/sln INSTEAD OF ln'.
20
Unix for Beginners
____________________________________________________________________________
VI-7 • dirtar:
If you want to archive or ftp a whole directory (tree), this is most efficiently done by first using
tar to archive all files into one archive file, compressing the resulting archive file and deleting
the original directory (tree). This script does the work for you.
VI-8 • tardir:
This script takes an output file from the previous script and restores the original directory
(tree).
21
Unix for Beginners
____________________________________________________________________________
VII - Miscellaneous
VII-1 • ftp:
File-transfer protocol; can be used to copy files from one computer (e.g. a VAX) to another.
Use something like: ftp -i xray.bmc.uu.se if you want to copy files from XRAY to an SGI or
ESV. If you copy from one UNIX machine to another, you may also use rcp (remote copy) or
uucp (UNIX-to-UNIX copy).
VII-2 • rlogin/telnet:
If you want to log on to another computer (e.g. a VAX or another UNIX machine), use either
rlogin (remote login; will not execute the .login file if you go to a UNIX machine) or telnet,
followed by the name of the host computer.
VII-3 • make:
If you have many or large programs to maintain, make is an excellent utility for you. The idea
is that you define a dependency-tree (the executable depends on the object files and libraries;
each object file depends on a Fortran file plus one or more include files, etc.) in a “makefile”.
If you have edited one subroutine file, all you have to do is type make executable_name, and
only that subroutine will be compiled and all object files and libraries will be linked together.
VII-4 • tar:
If you want to copy files to tape, you may use the tar command (tape archiver). To copy files
to tape, use something like tar cv ~bubba >& ~bubba/tarlist; to restore files, use tar xovp
(filename).
22
Unix for Beginners
____________________________________________________________________________
cal : print calendar
cron : execute commands at a specified date/time
mail/Mail : send and read mail
sort : sort or merge files
stty : set or list terminal characteristics
talk : talk to another user (like phone on the VAX)
time : time a command
which/whereis : locate a program or script
paste : list two or more file side-by-side
setenv : set environmental variables
printenv : list environmental variables
df : show disk usage
dd : file conversion
23
Unix for Beginners
____________________________________________________________________________
If you execute this “script” you will find that it doesn’t work. This is because the “#” on the
first line means that you want the child process to run in a separate C-shell, with its own
environment (directories etc.). This means that the process will start in your home directory
(/home/user), execute the .cshrc file (this can be avoided by starting the script file with
“#!/bin/csh -f” instead of with “#”) and then try to run XPLOR. This will fail since the file
xplor.inp does not exist in your home directory. In order to get the script to work, you have to
insert a line “cd xplor” between the two lines.
(7) source the modified script file; now the same will happen as in (6), except that any
statements executed in the sub-shell will also affect your own shell. Hence, if you have cd and
set statements in the script, they will put you in a different directory and (re)define certain
symbols ! This is the reason why, if you have altered your .cshrc file, you should always
source the new .cshrc file, rather than execute it.
VII-7 • generating files with instructions for all files of a certain kind: for example, get all files
named m24_cav*.o, put the string 'draw ' in front of each of them and put them in a file: \ls -c
m24_cav*.o | sed -e s/"m"/"draw m"/g > odraw.mac. The resulting file can be executed by
O immediately.
VII-8 • sed stream editor; for example: sed -e s/random/rannew/g conezd.com > new.com or
(using a script file) sed -f sed.script test.f > new.f.
VII-9 • X-windows programs (on SGIs at least): xedit - text editor; xfig -
"MacDraw/MacPaint" (use f2ps to get PostScript); xwd - window dump (redisplay with
xwud); xman - man pages; xmag - magnify a part of the screen; xfd - font display; xload -
show cpu load; xcalc - calculator; xclock - guess what; xterm - terminal window; xcalendar -
calendar & time management
VII-10 • use cut to grab certain columns or fields of a stream, for example: tty | cut -c1-9
gives: "/dev/ttyq"
24
Unix for Beginners
____________________________________________________________________________
- call perror (str*) => print str* and last detected error's
message to stderr
- call gerror (str*) => get last detected error's message
- i = ierrno() => return number of last error
- call qsort (...) => see man page
- call sleep (nsecs) => suspend process for nsecs seconds
- i = alarm(nsecs,extproc) => call external procedure after
nsecs seconds
- call system(str*) => execute str* as a sh-command
- time, ctime, stime, ltime, gmtime => see man pages
- str* = ttynam(iunit) => returns name of tty (or blanks)
- logi = isatty(iunit) => true if iunit is a tty
VII-14 • saving disk space: use compress (and uncompress) to reduce the amount of disk
space occupied by large, infrequently used files. The new file will have “.Z” appended to its
name. Use zcat to look at the contents of compressed text files without uncompressing them.
VII-15 • use the units command to convert between different units, e.g. kg to/from lbs.
VII-16 • the commands w and who tell you who is logged in on your machine
VII-17 • to find the factorisation of an integer number, use the factor command. This is very
useful when you are trying to find grids for CCP4 programs ! CCP4 does not allow you to
have grids which contain a factor > 19; so 134 is invalid since 134 = 2 * 67 and 67 > 19; 132
(2*2*3*11) and 136 (2*2*2*17) would both be okay
25
Unix for Beginners
____________________________________________________________________________
tr - translate or delete characters; useful for changing a file from UPPER- to lowercase, for
example: cat infile | tr '[A-Z]' '[a-z]' > outfile
spell - check a file for spelling errors
xedit - quick-and-dirty editor (gets its own window), for example (from O):
O > $ xedit map_macro &
limit - put the following line in your .cshrc file in order to avoid multi-megabyte core dumps:
limit coredumpsize 0
uuencode/uudecode - if you want to send BINARY files by E-mail, uuencode them:
uuencode binary_file coded_file > coded_file
banner - echo a text of up to 10 characters to the screen in BIG letters
26
Unix for Beginners
____________________________________________________________________________
VIII - Index of Unix commands
alias abbreviate common commands IV-17,V-2
alloc list allocated memory VII-5
apropos help on available commands IV-3
ar archive files VII-5
awk editor, stream-based IV-5
27
Unix for Beginners
____________________________________________________________________________
28
Unix for Beginners
____________________________________________________________________________
unalias remove an alias IV-17
uncompress decompress files V-2,VI-8,VII-14
units convert unit systems VII-15
unset remove a variable VI-1
uucp copy files from/to other machines VII-1
uudecode convert ASCII file back to binary VII-18
uuencode convert binary files to ASCII VII-18
29
Unix for Beginners
____________________________________________________________________________
IX - Inverted index of Unix commands
abbreviate common commands alias IV-17,V-2
add line numbers nl VII-18
archive files ar VII-5
archive files tar VI-6,VI-7,VI-8,VII-4
30
Unix for Beginners
____________________________________________________________________________
help xman VII-9
help on available commands apropos IV-3
help with a command man IV-3,V-2
31
Unix for Beginners
____________________________________________________________________________
remove directories rmdir IV-11
remove files rm IV-11,IV-17,V-2,VI-2,VI-6,
VI-7,VI-8
remove print job lprm IV-14
32