UNIX Primer Definitions
Name of Command | Short Description | UNIX Primer |
---|---|---|
cal | calendar | Page 39 |
who | who (is on system) | Page 40 |
finger | finger user(s) | Page 42 |
talk | talk to a user | Page 62 |
man | online manual | Page 64 |
ls | list directory contents | Page 79 |
cat | concatenate/display file | Page 80 |
more | show file 1 page by page | Page 83 |
pr | print to stdout | Page 85 |
mkdir | create new directory | Page 199 |
cd | change directory | Page 200 |
pwd | print working directory | Page 201 |
rmdir | remove directory | Page 201 |
rm | remove file(s) | Page 203 |
cp | copy file(s) | Page 205 |
mv | move or change filename | Page 207 |
ln | make file link(s) | Page 210 |
cc | C compiler | Page 236 |
f77 | FORTRAN compiler | Page 238 |
pc | Pascal compiler | Page 240 |
tee | splits output | Page 261 |
jobs | lists & IDs stopped & bg jobs | Page 269 |
ps | process status report | Page 270 |
kill | terminate job(s) | Page 271 |
history | prints list of last commands given | Page 279 |
alias | list or make aliases | Page 285 |
echo | echo arguments | Page 291 |
wc | word count | Page 310 |
tail | shows last part of a file | Page 312 |
head | shows head of a file (BSD) | Page 312 |
sort | sorts and merges files | Page 315 |
uniq | removes duplicated lines from a file | Page 317 |
lpr, lpq, and lprm | using the line printer | Page 320 |
chmod | change modes or permissions on files | Page 324 |
mesg | permit or deny messages from talk | Page 326 |
time | time a command | Page 329 |
calendar | a reminder service | Page 331 |
join | joins lines from two files | Page 339 |
grep | searches a file for a pattern | Page 374 |
find | searches designated files and acts upon them | Page 378 |
sort | sorts files | Page 384 |
Sorry about not having these terms alphabetized. Also, I'm not quite finished with all the terms. It'll probably be awhile before I can get back to this project... |
Example: To see the calendar for May 1942, type:
cal 04 1942
Options: None.
Arguments: [month] year
Select Another Term | | Back to Notes Menu |
Example: To find out who's on the system, type:
who
Options: Several.
Arguments: [am I]
Select Another Term | | Back to Notes Menu |
Options: [-l, -m, -s]
Arguments: [name...]
Example: To find out the login names of every user named "john," and to print just the one-line summary, type:
finger -s john
The results may look like this:
Login
jonny buny0234 daffy suzie john |
Name
John Grock John Bunyon John Duck Susan John Johannes Brahms |
TTY
5 17 18 19 22 |
Idle
<Jul 4 14:14> <Aug 2 06:02> <Aug 22 15:23> <Aug 17 09:42> |
When
12:13 |
Office
ACH000 CB122 MU244 |
Select Another Term | | Back to Notes Menu |
Options: None.
Arguments: user loginname
Select Another Term | | Back to Notes Menu |
Example: To display on the screen the on-line manual explanation of the cat command:
man cat
Options: Several.
Arguments: [section]
Note: man is usually quite slow in carrying out its service, so have patience.
Select Another Term | | Back to Notes Menu |
Options: [-a, c, l, -F, r, s, R + others]
Arguments: [directory...]
Example: To list the contents of the current directory in teh order that they were created, type:
ls -c
Comments: Remember that directories contain only the names of files and subdirectories. To read information contained in a file, use cat. Note that the option letters for ls may vary from system to system. This is true for many UNIX command options.
Select Another Term | | Back to Notes Menu |
Example: To display file2, type:
cat file2
Options: Several; not important here.
Arguments: [file...]
Comments: If no input file is given, cat takes its input from the terminal keyboard. Later in this chapter, we show that cat and redirection together are very useful. Note that the redirection operator uses the symbol >. You can use cat>file5 to create a new file called file5, and you can enter text into that file. You can use cat file2 file3>>file4 to append file2 and file3 to the end of file4.
Select Another Term | | Back to Notes Menu |
Key Pressed | Result |
---|---|
Spacebar Return d b h q |
Advances one screen. Advances one line. Advances eleven lines. Backs up one screen. Displays help screen. Quits. |
Example: To display the contents of the myths file, type:
more myths
Options: Several.
Arguments: [filename]
Select Another Term | | Back to Notes Menu |
Example: To print the file myths, type:
pr myths
The heading would include a line like:
May 1 12:29 1992 myths Page 1
To format the file myths and pipe the output to the printer rather than the terminal, type:
pr myths | lpr
Options: [l+others]
Arguments: [month] year
Select Another Term | | Back to Notes Menu |
Example:
mkdir Chapter4
This commands creates a new subdirectory called Chapter4 that exists in the directory where you entered the command. Note: You should not use a blank space in your directory names; typing mkdir Chapter 4 would create two directories. A handy convention is to name all directories starting with a capital letter.
Options: None.
Arguments: [directoryname...]
Select Another Term | | Back to Notes Menu |
Example: This command would place you in the /urs/reggie/Foods/Carbo directory:
cd/usr/reggie/Foods/Carbo
Options: None.
Arguments: [directoryname]
Select Another Term | | Back to Notes Menu |
Options: None.
Arguments: None.
Select Another Term | | Back to Notes Menu |
Example: This command removes the directories Budget65 and Budget66 if they do not contain any files:
rmdir Budget65 Budget66
Options: None.
Arguments: directoryname(s)
Select Another Term | | Back to Notes Menu |
Options: -i,-r
Arguments: filename(s)...
Example: This command will cause UNIX to query: rm: remove rodgers? And you reply with y or n for yes or no:
rm -i rodgers
Select Another Term | | Back to Notes Menu |
Example: This command makes a copy of the file flim and calls the copy flam:
cp flim flam
This command makes a copy of the file stormy (from the /usr/snoopy directory) and places the copy in the /urs/ruff directory:
cp/user/snoopy/stormy usr/ruff
Options: i, r.
Arguments: file1 file2 or file(s)...directory
Select Another Term | | Back to Notes Menu |
Example: (We assume that the user is in the /urs/flisk directory and that Hobo is a subdirectory of that directory.) This changes the name of the file mrak to mark:
mv mrak mark
The following command changes the name of the file mark (pathname /usr/flisk/mark) to /usr/flisk/Hobo/mark, thus moving the file to the Hobo directory:
mv mark Hobo
This changes the name of the file mray (pathname /usr/flisk/mark) to /usr/flisk/Hobo/mary, thus changing the directory and the tail of the pathname:
mv mray Hobo/mary
Options: -i
Arguments: filename1 filename2 or filename(s) directoryname
Select Another Term | | Back to Notes Menu |
Example: (We will assume that the current working directory is /usr/francie/Spring
and that there is a file called math in the /usr/francie directory):
This command creates the filename math in the current directory (/usr/francie/Spring) and links that name to the file called
math in the francie directory. The full pathname of the new link is /usr/francie/Spring/math:
ln /urs/francie/math
This command acts the same as the previous command except that the newly created filename is trig instead of math. The full pathname of the new filename is /usr/francie/Spring/trig:
ln /usr/francie/math trig
This command puts the two filenames hist and eng from the current directory into the /usr/francie directory:
ln hist eng /usr/francie
Options: None.
Arguments: filename1 [filename2] or filename(s) directoryname
Select Another Term | | Back to Notes Menu |
Example: The following command takes a C program from the file straight.c and the object code of a previously compiled C program from the file flush.o:
cc -o poker straight.c flush.o
The C program from straight.c is compiled, and the object code is placed in a file called straight.o. The two object codes are combined along with required C routines to form an executable program called poker. Typing poker will run the program.
Options: -c, -o
Arguments: file(s)
Select Another Term | | Back to Notes Menu |
Example: The following command takes the FORTRAN program in the file slop.f, compiles it, and places the object code for it in a file named slop.0:
f77 -o porker slop.f
It then takes the object code, combines it with the required FORTRAN support programs, and loads them into an executable file named porker. The program can be run by typing porker.
Options: -o, -c
Arguments: file(s)
Select Another Term | | Back to Notes Menu |
Example: The following command compiles the Pascal program in mask.p and places the object code for that program in the file mask.o:
pc -o zorro mask.p sword.o
It then combines this object code with the code in sword.o and with the system code to produce a complete program which is loaded into the file zorro.
Options: [-c, -o]
Arguments: file(s)
Select Another Term | | Back to Notes Menu |
Example: This command produces the long listing of the contents of the /usr directory. This listing is sent to the terminal screen, and it also is added to the end of the file, clutter:
Options: [-i, -a]
Arguments: filename(s)
Select Another Term | | Back to Notes Menu |
[1] + Stopped
[2] - Stopped [3] Running |
vi whatamess
vi fing ls -R / | sort -o jnk |
The first column is the assigned job number enclosed in brackets. The second column contains a + for the current job and a - for the next more current job. The third column states whether the job is stopped or running in background. The final column gives the name of the job.
The job command ranks by currency. From most current to least current, the order is as follows: most recently stopped job to least recently stopped job followed by the first initiated background job to the most recently initiated background job. In the example, the user went back to [1] after stopping [2] and then stopped [1] again.
The job numbers are assigned for a given terminal; if you use two terminals simultaneously, each will have its own list of job numbers.
Options: -l
Arguments: None.
Select Another Term | | Back to Notes Menu |
Options: [-a, -x]
Arguments: None.
Select Another Term | | Back to Notes Menu |
kill number
Example: Suppose the job spell Essay > err & has job number 3 and a PID of 3492. You can terminate the job with either:
kill %3
or
kill 3492
Options: -9
Arguments: job number or process ID
Select Another Term | | Back to Notes Menu |
set history=n
Identifying commands or events:
Identifying words within an event; the first word is number 0:
Special notations:
Examples:
This command repeats the previous command:
!!
This command causes event 5 on the history list to run:
!5
This command is run, substituting ls -l for ls:
^ls^ls -l
The command more is run on history event 5, from word 3 to the end of event 5:
more !5:3-$
Note that there are several modifiers that you can add to history substitutions. They consist of letters or symbols preceded by a colon. We'll leave it to you to investigate the online manual for details; see the sections on csh and newcsh. Most of the modifiers are more useful as components of UNIX programming than as casual aids.
Options: None.
Arguments: None.
Select Another Term | | Back to Notes Menu |
Name |
Options |
Arguments |
Example: |
alias |
None. |
None. |
(N/A) |
alias |
None. |
abbreviation command |
This command teaches UNIX a new name for the ls command:
alias list ls |
unalias |
None. |
abbreviation |
This command "turns off" the alias list that was set for ls:
unalias list |
For more details on using alias, see the text examples or the on-line manual discussion under csh. (This section of the manual is about 20 pages long with less than one page discussing alias.
Select Another Term | | Back to Notes Menu |
Example:
% echo say New York unique 10 times fast
say New York unique 10 times fast % |
Options: None.
Arguments: [any string of characters]
Select Another Term | | Back to Notes Menu |
Example: This command would count the nmber of words in the file essay:
wc -w essay
Options: [-lwc]
Arguments: [filename(s)]
Select Another Term | | Back to Notes Menu |
Example: The following command prints the last 20 lines of the file gate:
tail +30 gate
Options: [+/-number]
Arguments: filename
Select Another Term | | Back to Notes Menu |
Example: The following command prints the first 15 lines of the file hunter:
head -15 hunter
Options: [-number]
Arguments: filename(s)
Select Another Term | | Back to Notes Menu |
Example: The following command would sort the lines of the file grabbag:
sort -fr -o sortbag grabbag
Capitalization will be ignored by teh sorting process, and the lines will be in reverse alphabetical order. The results will be stored in teh file sortbag.
Options: [-d, -f, -n, -0, -r]
Arguments: filename(s)
Select Another Term | | Back to Notes Menu |
Example: The following command would scan the file ioulist for lines that appear more than once consecutively. One copy of each such line would be placed in the file urgent:
uniq -d ioulist urgent
Options: [-u, -d, -c]
Arguments:
inputfile
[outputfile] |
Select Another Term | | Back to Notes Menu |