Unix For Beginners - RTF MRW

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

Unix for Beginners ____________________________________________________________________________

UNIX for Beginners

Gerard J. Kleywegt Department of Molecular Biology University of Uppsala Uppsala - Sweden

With help from Alwyn Jones, Erling Wikman and Arnold Andersson

Version 1.0 @ 930111 Version 2.0 @ 940116 Latest update @ 9/10/2002 2:20 PM

Unix for Beginners ____________________________________________________________________________

I - Table of contents

Chapter/Section Item _________________________________________________________________ I II II-1 II-2 II-3 III III-1 III-2 IV IV-1 IV-2 IV-3 IV-4 IV-5 IV-6 IV-7 IV-8 IV-9 IV-10 IV-11 IV-12 IV-13 IV-14 IV-15 IV-16 IV-17 IV-18 V V-1 V-2 V-3 VI VI-1 VI-2 VI-3 VI-4 VI-5 VI-6 VI-7 VI-8
2

Page 2 4 4 4 5 6 6 7 8 8 8 8 8 9 9 9 10 10 10 11 11 12 12 13 13 14 14 16 16 16 17 18 18 18 19 19 19 20 21 21

Table of contents Introduction Literature What is UNIX ? About this guide UNIX versus VMS Commands Miscellaneous Basic concepts Logging in Commands Getting help Control characters Editors I/O streams File system Pathnames Listing directory contents Meta-characters Simple file manipulation Linking files Changing file permissions Manipulating text files I/O redirection History facility Aliases Job control Example files .login .cshrc Other files Example scripts compressor split repeat police forall sln dirtar tardir

Unix for Beginners ____________________________________________________________________________

VII VII-1 VII-2 VII-3 VII-4 VII-5 VII-6 VII-7 VII-8 VII-9 VII-10 VII-11 VII-12 VII-13 VII-14 VII-15 VII-16 VII-17 VII-18 VIII IX

Miscellaneous ftp rlogin/telnet make tar more commands Files versus processes sed sed X-windows programs cut system-dependent Fortran functions and subroutines command-line arguments in Fortran dynamic memory allocation in Fortran saving disk space units w and who factor some more commands Index of Unix commands Inverted index of Unix commands

22 22 22 22 22 22 23 24 24 24 24 24 25 25 25 25 25 26 26 27 30

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 Erlings room); - P.E. Bourne, UNIX for VMS Users, Digital Press, 1990 (in Alwyns 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). II-2 What is UNIX ? UNIX is a so-called operating system which nowadays runs on most computer systems. An operating system is merely a computer program through which the user interacts with the computer and its components and peripheral devices (processor, processes, files, disks, terminals, printers, plotters, etc.). Since every computer has one, operating systems are a necessary evil that you have to deal with if you do protein crystallography; on the other hand, knowing your operating system(s) well can make life a lot easier for you. UNIX was developed on a PDP-7 by Dennis Ritchie and Ken Thompson at Bell Laboratories in the late 1960s; it was first called UNIX in 1970. After 1975, UNIX developed along two separate branches leading to Berkeley (BSD) UNIX and System N UNIX (with N currently being V). Nowadays, System V UNIX is available on most computers but contrary to popular belief, there is no such thing as a standard UNIX version. Although the basic commands are available in most UNIX implementations, hardware vendors like to add nonstandard options and ditto commands to tailor their UNIX to their machines. Standardisation is, however, being undertaken by the Open Software Foundation (OSF) and, separately, by Unix International; the first proceed, OSF/1, is running on the new DEC Alpha computers. Since the mid-1980s approximately, UNIX has evolved into the operating system of choice for most machines (probably because it is cheap for a hardware vendor to adopt it), which means that users in a multi-vendor computer environment no longer have to learn a new operating system whenever they get a new computer (now they only have to familiarise themselves with the system-specific extensions). UNIX does have some strong points: it is fairly portable, flexible (i.e., easy to change, adapt and extend) and contains several powerful utilities. Also, it supports multiple users and multi-tasking. Nevertheless, UNIX is still very much an operating system for computer jocks (programmers); in skilled hands, it is very powerful, but to the novice end-user it is sometimes a nightmare (system-specific extensions, inconsistent syntax). Fortunately, on the modern graphics workstations more and more tools become available which make life easier (in this case, more Macintosh-like).

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.

A UNIX saleslady, Lenore, Enjoys work, but she likes the beach more. She found a good way To combine work and play: She sells C shells by the seashore.

A very intelligent turtle Found programming UNIX a hurdle The system, you see, Ran as slow as did he, And that's not saying much for the turtle.

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

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 ____________________________________________________________________________

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 !

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., dont use your own name, your cats 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 semicolons (;). If you need to continue a command on the next line, use the backslash character (\) at the end of the first line, etc. IV-3 Getting help: The help command under UNIX is called man (for manual); it has the syntax man command_name. Anther useful command: apropos anything (lists all commands which contain the string anything in their manual header). IV-4 Control characters: If you make mistakes while you type a command you may use: - CTRL-h or BACKSPACE to erase the last character - CTRL-w to erase the last word - CTRL-u to erase the whole line You may change these definitions in your .login file (e.g., to define CTRL-f as the erasecharacter keystroke, you would enter stty erase ^F). Other useful control characters are: - CTRL-s to suspend output to the terminal
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 Xwindows; emacs is not available on all machines; sed and awk are very powerful tools (they make a lot of jiffy programs obsolete) ! IV-6 I/O streams: There are three I/O streams associated with UNIX (see table). Under normal circumstances, standard input is expected from the keyboard and both standard output and standard error are associated with the terminal screen. As under VMS, input and (error) output can easily be redirected; in addition, under UNIX it is possible to pipe the output from one command or program straight into another one (this will be discussed later).
I/O stream stdin stdout stderr VMS-equivalent sys$input sys$output sys$error C unit 0 1 2 Fortran unit 5 6 6 default keyboard terminal terminal

IV-7 File system: UNIX organises information into files. Files are more than just collections of characters sitting on disks; in general, a file is a sequence of bytes of raw data. Files may therefore be executable programs, text files, data files, but also directory files, physical devices and communication channels (there even exists a non-file: /dev/null - whenever you want output to go down the drain, redirect it to this file). Files are organised hierarchically in a so-called directory tree; at the top is the root directory / (a single slash). On a system disk, this directory typically contains subdirectories such as bin (UNIX commands), etc (system files), tmp, lib (libraries) and usr. The usr directory in turn contains the home directories of the users of the machines (and their subdirectories). The home directory usually has the same name as the username; it is the users initial working directory when he or she logs in. IV-8 Pathnames:

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 Alwyns 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 Bubbas 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: Bubbas home directory. Bubba himself could also use ~/xplor/xplor.inp (a single ~ refers to ones 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-9 Listing directory contents: The ls (list) command lists the contents of a directory; the options you provide determine how much information is displayed (my favourite on SGIs is: ls -FartCos). A typical entry in a directory listing may look as follows:
-rwxr-xr-1 bubba 17632 Apr 1 23:59 xplode*

The first character indicates the file type; it may be: - ordinary file, d directory, b block device, c character device, l symbolic link or s socket. The next nine characters show the permissions (in three groups of three) of the user, other users in the same group and anyone else (in that order): r means read permission, w write permission and x (sometimes s) execute permission, whereas a - means that the corresponding permission has not been granted. The number (1) is the number of names that are linked to the file (default is 1, if the file is linked to other files this number will be higher). This is followed by the username of the owner of the file (bubba) and the size of the file in bytes (17632). The date and time when the file was last modified are also listed as is the actual name of the file (xplode). The * after the file line is produced by the -F option of the ls command and indicates that this is an executable file (program or script); the -F option will also put a / after directory files and an @ after linked files. 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 ____________________________________________________________________________

IV-11 Simple file manipulation: You may copy a file with the command: cp oldfile newfile; this will make an exact duplicate of oldfile; if newfile existed it will be overwritten (the -i option prevents this), otherwise it will be created. If you want to copy a file to another directory, the second argument should be the name of the target directory (i.e., not of the new file !): cp xplor.out ../notes will copy the file xplor.out to the sister directory notes. If you want to copy a file from another directory to your current directory, use either the absolute pathname of your current directory or simply a dot (., this always means current directory): cp ../notes/xplor.out . If you want to copy a directory structure, use cp -r dir1 dir2. A file can be removed with the command: rm myfile. If you want be prompted and asked if you really, really want to remove a file, use the -i option: rm -i file?.f etc. If you want to move or rename a file, use the command: mv oldfilename newfilename; this is equivalent to: cp oldfilename newfilename ; rm oldfilename. Use the -i option to prevent files from being overwritten. To create a new directory, use: mkdir newdir. To change directories, use the cd command; examples: cd xplor/old, cd ~billybob/mail, cd ../../joey etc. A directory which contains files can be removed completely in two ways: rm mydir/* ; rmdir mydir or rm -r mydir. There is one difference, however: the second method recursively deletes all sub-directories and their files as well ! IV-12 Linking files: A hard link allows you to assign multiple names to a single file (usually both files have to be on the same disk). It establishes another pathname to an existing file. For example, if you want to be able to edit a file lab_notes in all of your directories, you could create it in your home directory and later make links from all your subdirectories (you may give the linked files different names if you like). Now, whenever you edit any of the linked files the changes are made to all the files lab_notes since in reality they all correspond to one single file somewhere on the disk. The syntax is: ln existing_file link_file (note: if you swap the arguments you will effectively delete the existing_file !!!). A better way of linking is through so-called soft links; these can be made across disks and even to disks attached to computers which are physically quite far apart (so you could link a file in Stockholm to one in Uppsala). The link file really only contains a text string (the pathname of the file to which it is linked); this string is substituted whenever the name of the linked file appears in a pathname. A familiar example: ln -s /nfs/taj/alwyn/o/data odat (note the -s which makes this a soft link and please note the order of the arguments: existing file first !). Another useful example (if you use the scratch disk a lot): ln -s /nfs/scratch/bubba scr (now it will seem as if /nfs/scratch/bubba is a sub-directory called scr of your current directory). IV-13 Changing file permissions:

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. IV-14 Manipulating text files: The following commands are often used for manipulating text files: - cat filename : type the contents of the file on the screen - more filename : ditto, but paginated (type a SPACE to see the next page or a q to quit; some versions of UNIX offer the command less as well with which you can go back and forth in a file) - head filename : print the first 10 lines of a file (use: head -5 filename to see just the first five lines, etc.) - tail filename : print the last 10 line of a file; you may use the option -5 or -123 similar to head; if you use the option -f, the process goes into an endless loop printing everything that is added to the file to your screen (use this to monitor your XPLOR jobs, for example; terminate with CTRL-c) - grep string filename : list all occurrences of string in file filename; use the -i option to ignore uppercase-lowercase differences - wc filename : print the number of lines, words and characters in a file - cmp file1 file2 : tells you whether or not two files are identical - diff file1 file2 : finds differences between two files (on SGIs use /usr/sbin/gdiff; this is a window-mouse-based implementation of diff); use the -s or -r option to compare two directories - sort filename : sorts a file alphabetically or numerically; if you provide several filenames, the files will be merged and then sorted - lpr -Pprinter filename : print a file on the printer (in our lab: printer would be qms or 2up etc.); use the commands lpq to list current print jobs and lprm to remove them; use in conjunction with pr to get a nice listing including a header, the filename and page numbers, e.g.: pr -h Source -l80 prog.f | lpr -P2up

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 |. IV-16 History facility: The csh-command history lists previously issued commands (use -8 to get just the previous eight commands); the number of commands that is saved can be set as follows: set history=100 (you may want to put this into your .cshrc file). If you mistyped a command, you may use: ^wrong^correct to correct the typo and execute the command; for example, if you typed: who|sort|moer, type ^er^re next and the correct command who|sort|more is executed. To re-execute a previous command, use !: !! repeats the previous command, !142 repeats command number 142 (in the list produced by history), !l repeats the most recent command beginning with the letter l, !-4 goes back four commands and !?s? repeats the most recent command that contained the letter s. You may also extend previous commands, for example if the previous command was ls -l, you may type !! -a /usr | more which will result in the execution of ls -l -a /usr | more ! You may also recycle parts of previous command lines (for instance, long file names). The C-shell divides each command in separate words delimited by spaces or tabs. For example, if command number 5 in the history list was ls -al file1 file2 file3, then the command plus its options are called :0, the first file name is :1 or ^, the second file name :2 and the last file name :3 or $, while all files collectively may be referred to by *. The following table gives some of the possible history references for this command:

13

Unix for Beginners ____________________________________________________________________________ You type: !5 more !5:2-3 cat !5:$ more !5^ lpr !5:2 lpr !5* What is executed: ls -al file1 file2 file3 more file2 file3 cat file3 more file1 lpr file2 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. IV-18 Job control: A command may be executed in either the foreground or the background. Foreground jobs may read from and write to the terminal and the shell will wait until a command is finished before prompting the user for a new command. Background jobs may never read from the terminal (they will be stopped if they try to) but they may write to it (this can be switched off by stty tostop); the shell prompts for a new command without waiting for the command to complete. In order to execute a command in the background put an ampersand (&) after the command: xplor < x.in >& x.out &. The job will receive a background job number ([1], [2] etc.) and a process ID. When it is completed, a message like [2] Done xplor < x.in >& x.out will be displayed on your terminal. A job which was started in the foreground can be stopped with CTRL-z and then be continued in either the background (command bg) or the foreground (fg). The command jobs gives you a list of background jobs initiated at your terminal. If there are more than one, the one labelled + will be started if you type fg; if you want to start another one in the foreground, type %3 (to start job number 3). To stop a job running in the background, use stop %5; to terminate it completely, use kill %2.

14

Unix for Beginners ____________________________________________________________________________

To get information about your (and other peoples) 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 dont 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 SGIs 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 \!*'

V-3 Other files: Some other files in your home directory might be: .logout - csh-script which is executed when you log out .signature - your name and address, for example; will be appended to every mail you send .plan and .project - used by the finger command In addition, there may be window-manager specific files such as .chestrc, .4Dwm, .Xdefaults, and/or .sgisession. Examples of all these types of files can be found in (and copied from) /nfs/public/shell.

17

Unix for Beginners ____________________________________________________________________________

VI - Example scripts

The following script files can be copied from /nfs/public/shell. For more information on shellspecific 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.
# compressor ... gerard kleywegt @ 920318 # find /.. => search there (/ => entire file system) # -name .. => specify file names (-o is "OR-function") # -size ..c => specifies minimum file size in bytes # -type f => only look for files (i.e., not links or directories) # -atime +2 => only use files which haven't been accessed in two days # -exec .. => command to be executed for each "hit" (compress -v or ls) set echo find /nfs/taj \( -name '*.map' -o -name '*.o' \) -size +20000c -type f atime +2 -exec compress -v {} \; unset echo

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.
# split - gj kleywegt @ 920311 if (-e fsplit) then set sources=*.f set numfiles=$#sources echo Split $numfiles sources if ($numfiles == 0) then echo ERROR - no .f files in this directory ... exit -1 endif foreach file ($sources) echo ... splitting $file ... cp $file fsplit fsplit fsplit/$file \rm fsplit/$file end exit 0 endif echo ERROR - no subdirectory called "fsplit" here ... exit -2

18

Unix for Beginners ____________________________________________________________________________

VI-3 repeat: This script will execute a given command repeatedly at regular time intervals (using the sleep command).
# repeat - gj kleywegt @ 911025 if ($#argv < 2) then echo usage: repeat sleep_seconds command arg1 arg2 arg3 ... arg7 exit endif set echo while ($#argv > 1) $2 $3 $4 $5 $6 $7 $8 $9 echo "... I am going to sleep a little ..." sleep $1 end exit

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 theyre not owned by root), they will be reniced. This version of the script can only be executed by root.
# police - gj kleywegt - renice long-running non-root processes regularly # activate with: nohup /nfs/taj/police >& /dev/null & while (2 > 1) set allproc=`ps -ef | cut -c9-15 | sort` foreach proc ($allproc) if ($proc == "PID") then else set root=`ps -lf -p $proc | grep root | wc -l` if ($root == 0) then set nice=`ps -lf -p $proc | grep $proc | cut -c33-34` set cput=`ps -lf -p $proc | grep $proc | cut -c74-76` if ($cput > 60) then if ($nice < 39) then /etc/renice +19 $proc endif endif endif endif end sleep 600 end

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.
# forall file_id command - gj kleywegt @ 920803/920917 if ($#argv < 2) then 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'.
# sln - a SAFE soft linker - Gerard Kleijwegt @ 920812 if ($#argv < 2) then echo echo "usage: sln existing_file link_file" echo exit 1 endif set exist=$1 set linkf=$2 echo "sln - existing file : " $exist echo " - link file : " $linkf if (-f $exist) then \ls -FartCos $exist if (-f $linkf) then \ls -FartCos $linkf echo "WARNING - link file exists - overwrite (Y/N) ???" set answer=$< if ($answer == "y") then \ln -s $exist $linkf \ls -FartCos $linkf endif else \ln -s $exist $linkf \ls -FartCos $linkf endif else echo "ERROR - file does not exist" if (-f $linkf) then \ls -FartCos $linkf echo " - but the link file DOES ..." echo " - maybe you swapped the arguments ???" echo " - if so, try : sln " $linkf $exist endif endif

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.
# dirtar - gj kleijwegt @ 920803/921029 if ($#argv < 1) then echo echo "usage: dirtar dir_name" echo exit 1 endif set dirnam=$1 echo ... tarring $1 ... tar cvqqqf - $1 > $1.dirtar \ls -FartCos $1.dirtar echo ... compressing $1.dirtar ... compress -v $1.dirtar \rm -r $1 \ls -FartCos $1.dirtar.Z exit 0

VI-8 tardir: This script takes an output file from the previous script and restores the original directory (tree).
# tardir - gj kleijwegt @ 920803/921029 if ($#argv < 1) then echo echo "usage: tardir dir_name" echo exit 1 endif set dirnam=$1 echo ... uncompressing $1 ... \ls -FartCos $1.dirtar.Z uncompress -v $1.dirtar.Z echo ... untarring $1 ... \ls -FartCos $1.dirtar tar xovpf $1.dirtar \rm $1.dirtar \ls -FartCos $1 exit 0

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). VII-5 more commands:
file filenames date factor integer fold -75 file > newfile last -5 gerard strip file touch file alloc limit (-h) egrep/fgrep fsplit file f77 options files cc options files ar clear finger username od file : list the types of the filenames : print current time and date : print prime factors of an integer : fold long lines : print last 5 sessions of user "gerard" : strip an executable of unused routines : touches a file; changes date-last-changed : show allocated memory : show limits (memory etc.) : different versions of grep : split Fortran file into one file per routine : compile and link a Fortran file : compile and link a C file : archive and library maintenance : clear terminal screen : list information about a user : octal, decimal, hex, ASCII file dump

banner text_up_to_10_chars : prints large text on stdout

22

Unix for Beginners ____________________________________________________________________________ cal cron mail/Mail sort stty talk time which/whereis paste setenv printenv df dd : print calendar : execute commands at a specified date/time : send and read mail : sort or merge files : set or list terminal characteristics : talk to another user (like phone on the VAX) : time a command : locate a program or script : list two or more file side-by-side : set environmental variables : list environmental variables : show disk usage : file conversion

VII-6 Files versus processes: Files contain static information such as operating system commands (script files), Fortran or C instructions (program files), arbitrary text or data. Processes do the actual work; in general they execute programs (for example, a UNIX command or a program of your own or a CCP4 program). Each process has an environment which it inherits from its parent process. Whenever a sub-process is started, the parent process waits until it is finished, unless the subprocess is run in a batch queue or spawned. In addition, UNIX provides command line interpreters (comparable to VAX/DCL) which are called shells. You will probably use the standard C-shell (csh), but there are others (e.g., the Bourne shell and the Korn shell). Each type of shell offers an additional set of commands. An example may help to clarify these concepts: suppose that you are in directory /home/user/xplor and you want run XPLOR with an input file called xplor.inp. You then have the following options: (1) type xplor < xplor.inp: a sub-process will be created which inherits the characteristics of the parent (i.e., your terminal session), XPLOR will be run (in the directory /home/user/xplor) and when it is finished, control will be returned to your terminal. (2) type xplor < xplor.inp &: this does the same, except that the process will now be spawned; in other words, the XPLOR process will be run as a separate process and you will be able to continue to work in your terminal session while XPLOR is running. (3) create a file xplor.com which contains the line xplor < xplor.inp, change its protection to make it executable (chmod) and execute it by typing xplor.com; the effect will be the same as in (1) (4) now type xplor.com &; the effect will be the same as in (2) (5) modify the file xplor.com to read xplor < xplor.inp &; in this case, it doesnt matter whether or not you execute or spawn the file, in both cases control will be returned to the terminal almost immediately (6) modify xplor.com so that it contains the lines:
# script for running xplor xplor < xplor.inp &

23

Unix for Beginners ____________________________________________________________________________

If you execute this script you will find that it doesnt 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" VII-11 system-dependent Fortran functions and subroutines:
- call flush (iunit) - call fdate (str24) => flushes buffer of output unit IUNIT => returns date and time real(2)=elapsed system time, etime(..)=sum of these two - dt = dtime (real(2)) => ditto, but increments since last call to dtime - call getenv (nam,val) => returns value of env var NAM in VAL (both str*) - call getlog (str*) => returns user's login name - call idate (imon,iday,iyear) - call itime (real(3)) => array contains hrs,min,sec - i = mclock() => returns time accounting info

- et = etime (real(2)) => real(1)=elapsed user time,

24

Unix for Beginners ____________________________________________________________________________ - call perror (str*) - call gerror (str*) - i = ierrno() - call qsort (...) - call sleep (nsecs) => print str* and last detected error's message to stderr => get last detected error's message => return number of last error => see man page => suspend process for nsecs seconds 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

- i = alarm(nsecs,extproc) => call external procedure after

VII-12 command-line arguments in Fortran:


- narg = iargc () - call getarg (iarg, str*)

VII-13 dynamic memory allocation in Fortran:


pointer (iptr, arr) dimension arr(1) integer malloc,nbytes ... nbytes = 4*nvars iptr = malloc(nbytes) ... call free(iptr)

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 VII-18 some more commands: bc - arbitrary-precision arithmetic language nl - adds line numbers; handy in combination with cat/zcat/more, e.g.: nl myfile | more

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 alloc apropos ar awk banner bc bg cal cat cc cd chmod chown clear cmp compress cp cron cut date dd df diff du echo ed egrep emacs ex exit f77 factor fg fgrep file find finger fold fsplit ftp grep head history jobs jot kill

abbreviate common commands list allocated memory help on available commands archive files editor, stream-based list text in big letters calculator with arbitrary precision put job in background list calendar list file contents compile/link C program change directory change file protection change file ownership clear terminal screen compare files compress files copy files execute commands regularly extract columns from files list date and time convert files list file-system usage list differences between files list disk usage

IV-17,V-2 VII-5 IV-3 VII-5 IV-5 VII-5,VII-18 VII-18 IV-18 VII-5 IV-14,IV-15,V-2 VII-5 IV-11,V-2,VII-6 IV-13 IV-13 VII-5 IV-14 V-2,VI-1,VI-6,VI-7,VII-14 IV-11,VI-2 VII-5 V-2,VII-10 IV-17,V-2 VII-5 V-2,VII-5 IV-14,V-2 V-2

list to terminal V-2,VI-2,VI-3,VI-5,VI-6,VI-7,VI-8 editor, line-based IV-5 version of grep VII-5 editor, full-screen IV-5 editor, line-based IV-5 exit from a command script VI-2,VI-3,VI-4,VI-5,VI-7,VI-8 compile/link Fortran program list prime factors of a number put job in foreground version of grep list type of files find files list user information list file and fold long lines split Fortran source file copy files from/to other machines find/count string in files list file header list recent commands list jobs editor, window-based interrupt/terminate job V-2,VII-5 VII-5,VII-17 IV-18 VII-5 VII-5 IV-2,V-2,VI-1 V-3,VII-5 VII-5 VI-2,VII-5 V-2,VII-1 IV-14,IV-15,IV-17,IV-18,V-2 IV-14,V-2 IV-16,V-2 IV-18 IV-5 IV-18

27

Unix for Beginners ____________________________________________________________________________ last less limit ln logout lpq lpr lprm ls Mail mail make man mkdir more mv nice nl nohup od passwd paste pr printenv ps pwd rcp renice rlogin rm rmdir sed set setenv sleep sort source spell stop strip stty tail talk tar telnet time touch tr tty list last sessions of a user VII-5 list file contents, paginated IV-14 list/set hardware limits V-2,VII-18 link files IV-12,VI-5 stop a session V-2 list print jobs IV-14 print files IV-14,VI-5 remove print job IV-14 list files IV-9,IV-10,IV-16,V-2,VI-5,VI-6,VI-7,VI-8,VII-7 mail facility mail facility manage dependent files help with a command create directory list file contents, paginated move/rename files execute command with lower priority add line numbers execute command in background list dump of any file change password list two files side by side list file nicely list values of environment variables list processes list present work directory VII-5 VII-5 VII-3 IV-3,V-2 IV-11 IV-14,IV-15,IV-16 IV-11 IV-18 VII-18 IV-18 VII-5 IV-1 VII-5 IV-14,IV-17 VII-5 IV-18,V-2 IV-8

copy files from/to other machines VII-1 change priority of a command IV-18,VI-4 log in on other machine VII-2 remove files IV-11,IV-17,V-2,VI-2,VI-6,VI-7,VI-8 remove directories IV-11 IV-5,VII-7,VII-8 V-2,VI-2,VI-3,VI-4,VI-5,VI-6, VI-7,VI-8,VII-6 set environment variable V-2,VII-5 wait N seconds VI-3 sort files IV-14,IV-15,IV-16,IV-17,V-2,VII-5 execute script V-2,VII-6 check spelling VII-18 interrupt job IV-18 strip executable VII-5 set/list terminal characteristics IV-4,IV-18,V-1,VII-5 list file footer talk to other user archive files log in on other machine time a command change access date of files translate/delete characters list terminal IV-14,V-2,VI-5 VII-5 VI-6,VI-7,VI-8,VII-4 VII-2 V-2,VII-5 VII-5 VII-18 VII-10 editor, stream-based define value for a variable

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 vi w wc whereis which who xcalc xcalendar xclock xedit xfd xfig xload xman xterm zcat zip editor, full-screen list current users count lines, words, bytes in files list filename of program/script list filename of program/script list current users calculator calendar and time manager clock editor, window-based show available fonts draw pictures show CPU load help terminal window list contents of compressed text file editor, window-based IV-5 VII-16 IV-14,IV-15,IV-17 VII-5 VII-5 IV-15,IV-16,V-2,VII-16 VII-9 VII-9 VII-9 IV-5,VII-9,VII-18 VII-9 VII-9 VII-9 VII-9 V-2,VII-9 VII-14 IV-5

29

Unix for Beginners ____________________________________________________________________________

IX - Inverted index of Unix commands


abbreviate common commands add line numbers archive files archive files calculator calculator with arbitrary precision calendar and time manager change access date of files change directory change file ownership change file protection change password change priority of a command check spelling clear terminal screen clock compare files compile/link C program compile/link Fortran program compress files convert ASCII file back to binary convert binary files to ASCII convert files convert unit systems copy files copy files from/to other machines copy files from/to other machines copy files from/to other machines count lines, words, bytes in files create directory decompress files define value for a variable draw pictures editor, full-screen editor, full-screen editor, line-based editor, line-based editor, stream-based editor, stream-based editor, window-based editor, window-based editor, window-based execute command in background execute command with lower priority execute commands regularly execute script exit from a command script extract columns from files find files find/count string in files alias nl ar tar

IV-17,V-2 VII-18 VII-5 VI-6,VI-7,VI-8,VII-4

xcalc VII-9 bc VII-18 xcalendar VII-9 touch VII-5 cd IV-11,V-2,VII-6 chown IV-13 chmod IV-13 passwd IV-1 renice IV-18,VI-4 spell VII-18 clear VII-5 xclock VII-9 cmp IV-14 cc VII-5 f77 V-2,VII-5 compress V-2,VI-1,VI-6,VI-7,VII-14 uudecode VII-18 uuencode VII-18 dd VII-5 units VII-15 cp IV-11,VI-2 ftp V-2,VII-1 rcp VII-1 uucp VII-1 wc IV-14,IV-15,IV-17 mkdir IV-11 uncompress V-2,VI-8,VII-14 set V-2,VI-2,VI-3,VI-4,VI-5,VI-6, VI-7,VI-8,VII-6 xfig VII-9 emacs IV-5 vi IV-5 ed IV-5 ex IV-5 awk IV-5 sed IV-5,VII-7,VII-8 jot IV-5 xedit IV-5,VII-9,VII-18 zip IV-5 nohup IV-18 nice IV-18 cron VII-5 source V-2,VII-6 exit VI-2,VI-3,VI-4,VI-5,VI-7,VI-8 cut V-2,VII-10 find grep IV-2,V-2,VI-1 IV-14,IV-15,IV-17,IV-18,V-2

30

Unix for Beginners ____________________________________________________________________________ help xman help on available commands apropos help with a command man interrupt job interrupt/terminate job link list list list list list list list list list list list list list list list list list list list list list list list list list list list list list list files allocated memory calendar contents of compressed text file current users current users date and time differences between files disk usage dump of any file file and fold long lines file contents file contents, paginated file contents, paginated file footer file header file nicely file-system usage filename of program/script filename of program/script files jobs last sessions of a user present work directory prime factors of a number print jobs processes recent commands terminal text in big letters to terminal stop kill

VII-9 IV-3 IV-3,V-2 IV-18 IV-18

list two files side by side list type of files list user information list values of environment variables list/set hardware limits log in on other machine log in on other machine mail facility mail facility manage dependent files move/rename files print files put job in background put job in foreground remove a variable remove an alias 31

ln IV-12,VI-5 alloc VII-5 cal VII-5 zcat VII-14 w VII-16 who IV-15,IV-16,V-2,VII-16 date IV-17,V-2 diff IV-14,V-2 du V-2 od VII-5 fold VII-5 cat IV-14,IV-15,V-2 less IV-14 more IV-14,IV-15,IV-16 tail IV-14,V-2,VI-5 head IV-14,V-2 pr IV-14,IV-17 df V-2,VII-5 whereis VII-5 which VII-5 ls IV-9,IV-10,IV-16,V-2,VI-5, VI-6,VI-7,VI-8,VII-7 jobs IV-18 last VII-5 pwd IV-8 factor VII-5,VII-17 lpq IV-14 ps IV-18,V-2 history IV-16,V-2 tty VII-10 banner VII-5,VII-18 echo V-2,VI-2,VI-3,VI-5,VI-6, VI-7,VI-8 paste VII-5 file VII-5 finger V-3,VII-5 printenv VII-5 limit V-2,VII-18 rlogin VII-2 telnet VII-2 Mail mail make mv lpr bg fg unset unalias VII-5 VII-5 VII-3 IV-11 IV-14,VI-5 IV-18 IV-18 VI-1 IV-17

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 set environment variable set/list terminal characteristics show CPU load show available fonts sort files split Fortran source file stop a session strip executable talk to other user terminal window time a command translate/delete characters version of grep version of grep wait N seconds setenv stty xload xfd sort fsplit logout strip talk xterm time tr egrep fgrep sleep V-2,VII-5 IV-4,IV-18,V-1,VII-5 VII-9 VII-9 IV-14,IV-15,IV-16,IV-17, V-2,VII-5 VI-2,VII-5 V-2 VII-5 VII-5 V-2,VII-9 V-2,VII-5 VII-18 VII-5 VII-5 VI-3

32

You might also like