UNIX
BASICS
|
|
|
This How-To introduces basic concepts about UNIX
systems and provides instruction on common UNIX commands,
including those you can use to manage your files. The narrative
text is followed by a "UNIX Command Quick Reference"
that summarizes the syntax and description of each command covered
in this section. Additional related information can be found in
the chapter "UNIX Computer Accounts" and the How-To
section "Logging In to your UNIX Account via Telnet."
|
The UNIX File System
|
In order to get the most out of your UNIX account,
it's important to understand a little about the UNIX file system.
Large UNIX machines, like the ones CCSO manages, can hold tens of
thousands of files. These files are organized into directories
forming a hierarchical structure similar to the folders on
Macintoshes or directories on PCs. The highest level of this
structure is called the root directory, and is represented
by a forward slash (/). The root directory generally contains
other directories, called subdirectories, but may also
contain files. Subdirectories can contain both files and more
subdirectories. This hierarchy of files and subdirectories can be
many levels deep.
Every user with a login on the system has a special directory,
called a home directory, where personal files can be
created and stored. The name of each home directory is the same as
its owner's account login.
The diagram below shows part of a typical UNIX file
system. Four subdirectories of the root directory are shown. Items
ending with a slash, such as j/ and k/, are
subdirectories. Items without a trailing slash are files. The home
directories are grouped by letters of the alphabet under the home
subdirectory.
|
Understanding Absolute and
Relative Paths
|
If you ever need to copy or move files from one
directory to another, in addition to knowing the names of the
files and directories, you will also need to know how to write out
their paths. A path describes the location of a file or
directory in relation to other directories. There are two types of
paths, absolute and relative.
|
Absolute Paths
|
An absolute path describes the exact location
of a subdirectory or file, starting from the root directory.
For instance, in the diagram above, the absolute path of the file
named index.html in kay's public_html directory is:
/home/k/kay/public_html/index.html
The initial slash in the absolute path represents
the root directory. All subsequent directories are written in the
form directory_name/. Each slash in the path
chows the separation between a directory and a subdirectory or a
file contained within it.
|
Relative Paths
|
Unlike an absolute path, which never changes, a
relative path can vary because it is defined in relation to
the current working directory-that is, whatever directory
you are in at the moment. Since a relative path does not start at
the root directory (unless the root directory happens to be the
current working directory), it does not begin with a slash. If the
leftmost item in a relative path is the name of a directory, the
directory is assumed to be in (or under) the current working
directory. Referring to the file system diagram again, if the
current working directory is /home/k/kay, the relative path
of the file named index.html in kay's public_html
directory is:
public_html/index.html
When writing out a relative
path, the sequence .. (two periods in a row) means
"parent of current working directory," or "up one
directory." (The directory containing a directory is called
its parent.) By using this notation, you avoid having to
type all the names in a sequence of parent directories. The
relative path from kay's home directory to the file index.html
in joe's public_html subdirectory is thus:
../../j/joe/public_html/index.html
In plain English, the above path means "up one
directory (from kay to k), then up another directory
(from k to home), then down from the directory home,
through j and joe, to public_html where the
file index.html is located.
When
specifying relative paths it is imperative that you know the
current working directory. If you lose track of your location, the
UNIX command pwd (print working directory) will display the
absolute path of the current working directory on your screen.
|
The ~(Tilde) Path
|
There is another way to specify a path, pertaining
only to home directories. The tilde (~) character can be used as a
shorthand method of writing the absolute path to any home
directory. When a tilde is followed by a login (e.g., ~joe),
it signifies the home directory for that login. Using the tilde,
another way to write the path of the file index.html in
joe's public_html directory is:
~joe/public_html/index.html
When referring to your own home directory,
you don't need to specify a login. A tilde by itself is shorthand
for the home directory of the person who is logged in. Thus if kay
were logged in to her account, she could refer to her own
index.html file with the following path:
~/public_html/index.html
|
Search Paths: Another Kind of Path
|
Occasionally, when you try to start a UNIX program,
you may get a "not found" or "Command not found"
error. This can happen even fhen you are absolutely sure that the
program you want to run is available on the system. It usually
occurs when the program is not in your search path. A
search path is a preconfigured list of directories in which the
system expects to find program files.
For most users, the search path is set during the login process
when the configuration files, known as dot files, are read.
You can see your default search path by typing the following
command at the UNIX prompt:
printenv PATH
The output of the above command will look something
like this:
/usr/local/bin:/bin:/usr/bin:/usr/ccs/bin:/usr/games:/usr/ucb:.
As shown in the sample output above, each directory
in the search path is separated from the next by a colon. When the
system looks for a program, it searches the leftmost directory
first (/usr/local/bin in the above example) and continues
to search each directory in the list until it finds a program with
the name you typed, at which point the program is executed. If a
program by the same name is located in two different directories
in your search path, the system will execute the first one it
finds. To start a program that isn't in your search path, type out
the fell or relative path of the program as described in the
previous section.
|
Typing Commands at the UNIX Prompt
|
There are many UNIX commands for carrying out file
and disk space management tasks such as listing files, removing
files, creating directories, and removing them. These commands are
generally abbreviations of the names of the tasks they perform,
and hence are fairly easy to remember-for example, ls lists
files, and cd changes directories.
When writing out a command, the various parts of the command must
follow a specific order, called the command syntax. The
parts include the command itself, any added command options, and
the names of files or directories to be acted on by the command.
Syntax varies among UNIX commands. For instance, some commands
take file or directory names as part of their syntax, whereas
others do not. However, file and directory management commands
generally have the following syntax:
command [options]
file_name(s) or directory_name(s)
Options change how the command is carried out or
alter the type of output produced by the command. They take the
form x, where the minus sign (-) indicates that the
letter immediately following it is an option, and the ldtter (x)
represents a particular option. Multiple options can usually be
employed simultaneously in the form xyz (rather than
writing as xyz).
Many commands take the names of files or directories
as part of their syntax. If you type the name of a file or
directory by itself (i.e., without its relative or absolute path),
it is assumed to be in your current working directory. To refer to
files or directories outside of the current working directory, you
must specify their relative or absolute paths.
Note: In the remainder of this How-To, the
UNIX prompt is shown as $. The prompt may be different on
the system you're using.
|
Listing Directory Contents
|
The command ls lists the contents of
directories and provides information about files. Various options
of ls modify the information provided in its output. The
simplest form of ls (without any options, or file or
directory names) produces an alphabetical list of the names of all
the files (except dot files) and subdirectories in the current
working directory. Here is an example:
$ ls final_paper
homework1.30 mail homework1.16 homework2.13
public_html $
Giving the name of a directory as an argument to the
ls command causes ls to display the contents of that
directory rather than the current working directory. For example:
$ ls
public_html index.html $
To view dot files (those files whose names begin
with a period), use the -a option, which shows all
files:
$ ls
-a .
.kshrc .profile
homework1.30 ..
.mh_profile .sh_history homework2.13 .addressbook
.nfsB3A1 final_paper mail .exrc
.nn
homework1.16 public_html $
Another option, -l, produces a long format
listing of the directory contents. This shows detailed information
for each file and directory:
$ ls
-al total 106 drwx--l--- 5
joe home 1536 Jan 30 13:10
. drwxr-xr-x 1482 root home 27136
Jan 29 14:40 .. -rw-r----- 1
joe home 0 Aug
31 1994 .addressbook -rw-r--r-- 1
joe home 7175 Jan 29 15:11
.kshrc -rw-r----- 1 joe
home 9 Sep 6 1992
.exrc -rw-r----- 1 joe
home 11 Jul 2 1992
.mh_profile -rw------- 1 joe
home 360 Jan 30 13:13
.nfsB3A1 drwx--l--- 2 joe
home 512 Jan 11 15:55 .nn -rw-r--r--
1 joe home 1004
Jan 29 15:13 .profile -rw------- 1
joe home 770 Jan 29 15:13
.sh_history -rw------- 1 joe
home 1743 Jan 5 14:16
final_paper -rw------- 1 joe
home 1216 Jan 11 14:41
homework1.16 -rw------- 1 joe
home 1216 Jan 11 14:41
homework1.30 -rw------- 1 joe
home 1216 Jan 16 11:46
homework2.13 drwx------ 2 joe
home 512 Jan 11 15:54 mail drwxr-sr-x
2 joe home
512 Jan 17 10:05 public_html $
Example entry:
|
permissions
|
links
|
owner's login
|
group
|
size (bytes)
|
date/time last modified
|
file name
|
-rw-------
|
1
|
joe
|
home
|
1216
|
Jan 16 11:46
|
homework2.13
|
The information you are most likely to use from a
long-format listing is labelled in the above example. You may wish
to pay special attention to file size, since too many large files
can fill up your disk space. Permissions determine who may read,
write, or execute each file and directory. Only the owner of a
file or directory can change its permissions. In the above
example, the user joe is the owner of all the files and
directories shown. For a detailed discussion of permissions, see
the section "Sharing and Protecting your Files and
Directories" later in this How-To.
|
Wildcards:
Shortcuts to File and Directory Names
|
Wildcards are special characters reserved for
filling in any character or string of characters when typing the
name of an existing file or directory. They are particularly handy
when typing a long or unwieldy file or directory name, or when you
want to make a command apply to a group of similarly named files
or directories. The most commonly used wildcard is the asterisk
(*), used to mean "zero or more occurrences of any and
all characters." For example, to list all files beginning
with .m, use the following command:
$ ls
.m* .menueditorprog .menumotd
.menushellprog .menumailprog .menunewsprog
.mh_profile $
You can use multiple wildcards in the same name. For
example, if you have files as shown on the long listing in the
previous section above, an easy way to list only the files
homework1.16 and homework1.30, is to use the command
lsh*1.*. Be very careful when using wildcards to delete
files, because your command could remove more files than you
originally intended. To ensure that you know what files a wildcard
expression represents, it's a good idea to use the wildcard
expression in an ls command before using it with a command
that can modify or erase your files. Note, for instance, that
leaving out the period from the example above produces a list of
all the homework files:
$ ls
h*1* homework1.16 homework1.30 homework2.13 $
|
Moving Between Directories
|
When you log in, your initial working directory is
your home directory. You can move up and down the UNIX file
structure using the change directory command, cd.
The cd command usually requires you to specify the name of
the directory you want to change tn (i.e., cddirectory_name).
You can either specify an absolute path to another directory
(i.e., cd/home/k) or a relative path (i.e., cd../mail).
Typing only cd will return you to your home directory.
|
Checking your Disk and File Quotas
|
Some day, you may get a message from the UNIX system
stating that you have "exceeded your limit," or "reached
your quota." These messages indicate that you have used up
all the disk space allocated to you, either in your home
directory, or in your incoming mailbox (also called your mail
spool). Until you free up some disk space, you will not be
able to create or save any files. This may prevent you from using
programs that modify files in your home directory, such as email
programs or news readers.
To see your current disk usage and limits, use the quota -v
command. The following is an example of typical quota output on
the student cluster:
$ quota
-v Disk quotas for joe (uid 9593): Filesystem
usage quota limit timeleft files quota limit timeleft /homeb
368 4096
4300 94
2000 2500 /homec 0
1 1
0 1 1 $
In the Filesystem column, two file systems
are shown, /homeb and /homec. All student home
directories are in the /homeb directory. Faculty and staff
home directories are stored in /homea, which does not show
in the above output. As a student, joe need only pay
attention to the data given for the /homeb file system.
When reading the quota output, your current
disk usage (counted in 1 kilboyte blocks) is reflected in
the usage column, and your total number of files is shown
in the files column. The quota columns indicate the
point at which the system will complain that you hare too many
files or are using too much of your allotted disk space (also
counted in 1 kilobyte blocks). The limit columns indicate
the absolute maximum amount of disk space or number of files you
can use. Think of the difference between the quota and the
limit as a buffer. Once you've surpassed your quota, the
relevant timeleft (called grace on ux7)
column will start a count-down - you have seven days to reduce
your disk usage or number of files. After seven days you will no
longer be able to do anything other than delete files.
If
you get a message from the system stating that you've exceeded
your disk space quota, immediately delete some of the files in
your home directory, transfer them to a different system, or
compress them so that they take up less space. Various compression
programs are available on the CCSO UNIX systems, including
compress, gzip, and zip. You can learn more
about these compression programs using the UNIX online
documentation. For help, see the section below that discusses
"Using Online UNIX Documentation."
|
Incoming
Mailbox Quotas
|
Your mail spool is checked by the system each time
you log in-if you have exceeded your mail quota, the system will
send you a warning. If this happens, you should read your mail and
either delete the messages or save them as files in your home
directory. Don't leave messages in your incoming mailbox.
|
Managing Your Files
|
When you are logged in to your UNIX account, if you
download free software from a server or save an e-mail message or
a news article, you are writing to the disk space in or below your
home directory (unless you specify a different path). These tasks
involve either creating new files, or appending to existing ones.
As the number of files in your account increases, you may vish to
reorganize them to suit your current needs. You can create
directories to organize your files, and move files among
directories as your activities dictate. You can also copy and
rename files and directories, and remove them when they're no
longer needed.
|
Creating Directories
|
Directories are the main organizational tool on a
UNIX system. You can use them to organize related files just as
you would on a desktop system (i.e., using folders on a Macintosh,
or directories on a DOS/Windows system). The command mkdir is
used to create new directories. It always takes the name of a new
directory as an argument, as in mkdirdirectory_name.
For example, to create a new directory called myhomework
beneath the current working directory, use the command:
$ mkdir
myhomework
|
Moving and Renaming Files and Directories
|
In UNIX, the command, mv, is used both to
rename files and directories and to move them to other locations.
The mv command always takes two arguments, either two file
names, two directory names, or one of each. To rename a file or
directory, the syntax is mv old_name new_name.
For example, to rename the file called homework in the
current working directory to homework.cs101, type:
$ mv homework
homework.cs101
If used incorrectly, mv can be a dangerous
command. For instance, if a file already exists with the name
homework.cs101, the mv command will remove that
existing file, replacing it with the one that's being renamed.
This may not be what you want. It is safer to use the interactive
option (-i) with mv so that the system prompts you
to confirm before removing any files. For example:
$ mv -i
homework homework.cs101 remove homework.cs101?
(y/n) n $
The mv command can also be used to move files
or directories to other locations. If you want to move a file from
one directory to another, the syntax is mv file_name
directory_name. For example, to move all the homework
files in the current working directory to an existing subdirectory
called cs101, type:
$ mv -i
homework* cs101
The cs101 directory must already exist for
the above command to work. The -i option forces the system
to prompt you before removing any files of the same name.
The table below shows the various ways the mv
command can be used:
mv Command
|
|
Action
|
|
mv old_name new_name
|
|
Rename a file or directory.
|
mv file_name directory_name
|
|
Move a file to an existing directory.
|
mv directory_name1 directory_name2
|
|
Move a directory (and all files therein) to a
different directory. Directory_name2 must already exist,
or this command will simply rename directory_name1 to
directory_name2.
|
|
|
Copying Files
|
The copy command, cp, creates an exact
duplicate of a file. It always takes two arguments, the name of
the original file and the name or location of the copy to be
created. By necessity, the new file must have a different absolute
path than the original-that is, it must either have a different
name, or if it has the same name, it must reside in a different
directory. Like rm and mv, cp can take the -i
option to force the system to prompt you before removing any
existing files.
To make a copy of a file in the current working
directory, use the syntax cpfile_namecopy_file_name,
as shown in the following example:
$ cp -i
final_paper econ101_paper
The table below shows the various uses of the cp
command:
cp Command
|
|
Action
|
|
cp file_name copy_file_name
|
|
create a duplicate of the file in the current working
directory
|
cp file_name directory_name
|
|
create a duplicate of the file in the directory specified
(the copy will have the same name as the original, but reside
in a different directory)
|
cp file_name1 directory/file_name2
|
|
create a duplicate of the file in the directory
specified, and give it a different name as specified
|
|
|
Combining Files
|
The cat command can be used for combining the
contents of one or more files into a new or an existing file. To
create a new file from the contents of one or more existing files,
use the redirection symbol, > , as in cat file_name1
file_name2>new_file . The files
will be combined serially in the order specified. Note: Be
careful when using redirection; if a file called new_file
already exists, it will be overwritten! To append one or more
files to the end of an existing file, use the >>
redirection symbol instead, as in catfile_name1
>> file_name2 .
|
Removing Files
|
When files are removed in UNIX, they are lost
forever. There is no "undelete" command. Therefore, it
is important to be careful when purging your files. The UNIX
command for removing files is rm, and it takes the name of
an existing file as an argument, as in rm file_name.
Especially when removing a group of files, it is safer to use the
interactive option, -i, so that the system prompts you to
type y(es) or n(o) before it deletes the file(s).
For example:
$ rm -i
homework* rm: remove homework1.16 (y/n)? n rm:
remove homework1.30 (y/n)? y rm:
remove homework2.13 (y/n)? y $
Remember, rm is forever; -i give you
one last chance.
|
Removing Directories
|
The rmdir command is used to remove
directories, as in rmdir directory_name. It
operates exactly like the rm command, and takes the
interactive option (i) as well. Directories must be
empty-that is, they must not contain any files or subdirectories
before they can be removed with rmdir.
|
Sharing and Protecting your Files and
Directories
|
The chmod command is used to change the read,
write, and execute permissions on files and directories. If you
have specific files you want to share with others, such as the
files making up your personal Web pages, you must change their
permissions before others can view or change them.
There are four parts to the chmod command-the
who option(s), the opcodes (i.e., operation codes),
the permission option(s), and the name of the file or
directory for which permissions are to be changed:
Who Options
|
|
Opcode Options
|
|
Permissions
|
|
u user
|
|
+ add permission
|
|
r read
|
g group
|
|
- remove permission
|
|
w write
|
o other
|
|
= assign permission
|
|
x execute
|
a all of the above
|
|
|
|
|
|
Who specifies who the permission affects, the
user (u), the group (g), others (o), or all
three (a). The user is the owner of the file or
directory, the group consists of those with whom the owner
shares a group id (on CCSO UNIX systems, if you're a student, this
generally includes other students; if you're faculty/staff, it
includes people in your campus unit), and other represents
all othdr users on the system. The opcode part of the chmod
command specifies whether a permission is added to (+),
removed from (), or simply assigned to (=) the who
specified. The permission specifies the type of access that
is being added or removed, namely read (r), write (w),
or execute (x).
The following example shows the structure of the
chmod command:
chmod g+r file_name
-
change mode command
|
who
|
opcode
|
permission
|
file to be changed
|
chmod
|
g
|
+
|
r
|
file_name
|
A good way to understand a chmod command is
to read it aloud. The previous example reads "change mode for
group; add read permission on the file file_name."
The permissions associated with a file or directory
can be viewed using the long format list command, lsl. The
example below shows the permissions for the file findit.sh:
-rwxrwxrwx
1 joe home
1216 Jan 13
8:22 findit.sh
-
type
|
user
|
group
|
other
|
-
|
rwx
|
rwx
|
rwx
|
Permissions are expressed by a series of ten
characters, consisting of letters and dashes. The first character
identifies the object's type; a dash (-) represents a file,
a d represents a directory. The next three characters
indicate the read (r), write (w), and execute (x)
permissions of the user (owner) of the file, the second set of
three indicates the group's read, write, and execute permissions,
and the last three, all others' read, write and execute
permissions. Read, write, and execute are always found in the same
position for each category of who. A dash appearing in any
one of the nine positions means the corresponding permission is
turned off. If a letter (i.e., r, w, x)
appears, the permission is turned on.
In the above example, the user joe, his
group, and all other users have read, write and execute access to
the file findit.sh. The initial dash indicates that the
item is a file. If it were a directory, the first bharacter would
be a d instead of a dash.
|
Examples of the chmod
Command
|
The following example shows how to remove others'
read, write, and execute permissions from a file named
homework1.16:
$ chmod o-rwx
homework1.16
To check that the permissions have been changed,
list the file with ls -l:
$ ls -l
homework1.16 total 8 -rwxrwx--- 1 joe home 1216
Jan 13 8:22 homework1.16
Adding, or granting, permissions can be accomplished
using the add (+) or assign (=) opcodes. For example, to
give others read and write permissions again, you could use the
command:
$ chmod o=rw
homework1.16
Multiple who, opcodes, and permissions
can be used together, as long as a comma (but no spaces) separates
each combination (if they are different), and a space separates
each file or directory name if more than one is specified. For
example, you can simultaneously change permissions on two files at
once, granting read, write, and execute permission to your group,
but only read and write permission to all others, as follows:
$ chmod
g=rwx,o=rw homework1.1 econ101_paper
Or, if the same opcode and permissIons are being
used for each who, they can be combined without commas. The
following example adds read and write permissions for the group
and others to the file homework1.16:
$ chmod go+rw
homework1.16
The chmod command works exactly the same way for
directories. Important: a directory must be made executable
in order for anyone, including yourself, to be able to make it the
current directory (i.e., to cd into it) and read a file in
it. Because of this, if you want people to be able to read your
Web pages (from UIUC or from Tokyo), you must add croup and other
executable permissions to both your home and public_html
directories (i.e., chmodgo+x~public_html).
|
Using Online UNIX Documentation
|
All UNIX systems have online documentation or
manuals, called man pages,for UNIX programs and commands.
The program man is used to display the documentation for
the command or program that you specify, as in mancommand.
For example, to view the man page for the newsreader nn,
you would type the command:
$ man nn
If you cannot recall the exact name of the command
you want to look up, or you don't get the desired output using the
form mancommand, try using the -k
option to search the man pages for a particular keyword, as in
mankkeyword. This displays a listing of
summaries for all man pages that contain the keyword (sometimes
the resulting output can be quite long). >From this list you
can choose the appropriate man pages to browse. For example:
$ man -k
remove prunehistory (8) - remove file names from
Usenet history file prunehistory (8) - remove file names from
Usenet history file rm, rmdir (1) - remove (unlink) files or
directories rmdir (2) - remove a directory file rmdir, rm
(1) - remove (unlink) directories or files rmf (1) - remove an
MH folder [output omitted]... $
Sometimes you will see a number in parentheses after
the name of the program or command. This is the volume number of
the manual set. By default, when you type man nn, you are
looking in volume 1. If you would like to see the manual pages for
a command in a different volume, you need to specify the volume
number. For example, to see the man page for 'prunehistory' shown
above, type:
$ man 8
prunehistory
|
Viewing Files
|
Several UNIX commands can be used to view the
contents of files without using an editor. These commands have a
variety of uses. Before removing a file, for instance, you'll
probably want to make sure you know what's in it. You may want to
read a file, but not want to edit it or take the chance that it
might be changed by accident.
|
Viewing
a File All at Once
|
The concatenate command, cat, displays a file
on your screen, from first line to last without stopping (i.e.,
catfile_name). If a file is large, cat
will probably display it too quickly for you to read all but the
very end, but it does give you a fast glance at the contents,
reminding you of what's in the file.
|
Viewing a File One Screen at a Time
|
The program more is a pagerit allows
you to browse through a file, one screen at a time, without
invoking an editor such as Pico or vi.
As you page through a file with more, an
indicator in the lower left corner of the screen shows you how
much of the file has been displayed. To advance one screen at a
time, press <SPACE>, or proceed one line at a time by
pressing <RETURN>. Several other navigational
commands are also available within more, including a
command to search for a particular word or phrase. Here is a
summary of useful more keystrokes:
more Keystroke
|
|
Result
|
|
<SPACE>
|
|
display next page
|
<RETURN>
|
|
display next line
|
d
|
|
Scroll forward (down) one-half page
|
f
|
|
skip forward one page
|
b
|
|
skip backward one page (on students and staff)
|
/string
|
|
search for occurrence of string
|
n
|
|
search for next occurrence of specified string
|
h
|
|
help
|
q
|
|
exit from more
|
|
|
Printing Files
|
On CCSO UNIX systems, the out command can be
used to print files. You must specify a destination printer with
this command, as in:
out -dest printer_name
file_name
Here are some publicly accessible printer
destinations for out:
Printer Name
|
|
Type and Location of
Printer
|
|
3800
|
|
IBM 3800 Laser printer, L440 DCL
|
ag3812
|
|
IBM 3812 Laser printer, N-120 Turner Hall
|
comm
|
|
high-speed printer, 70 Comm West
|
dcl
|
|
IBM 3203 printer, L441 DCL
|
fax
|
|
outbound fax service
|
lincoln
|
|
HP LaserJet 3si, OCCSS at 212 Lincoln Hall
|
ps3812
|
|
IBM 3812 Laser printer, 493 Lincoln Hall
|
psych
|
|
IBM 3262 Line printer, 453 Psychology
|
|
The out command can take a number of
additional options (some depending on the destination of the print
job). The syntax of the out command with several of the
more common options is shown below:
out -dest printer_name
-bin value -banner string
file_name
The -bin option takes a numeric value (i.e.,
-binvalue) that references a numbered bin
that is used to store the print job at the printer site until it
is picked up by the sender. The -banner option takes a
character string, such as a name or file identification (i.e.,
-bannerstring), that is printed in large
lettdrs on the banner (first) page of the print job. If -banner
is not specified (or not active for a particular printer),
publicly accessible destinations will print a banner page showing
the sender's login.
Below is example of the out command with
multiple options, followed by the system message that is returned:
$ out -dest
lincoln -banner JOSEPH econ101_paper 200 CSO Print
Server v3.2 (22 Aug 14:20). Say your request. 200 Cleared as
filed, squawk 2435. Remember the above squawk code; you'll need
it to identify your job if you need to cancel or inquire about it
later. $
Part of the system message
is the squawk code-an identification number assigned to
each print job. If you must cancel your print job, or if it gets
lost or never prints out, you need to know the squawk code in
order to have the problem investigated.
Each out destination may have additional
options for customizing print jobs. Some destinations also have
restrictions. To find out what they are, use the command:
out -info printer_name
The example below shows information for the printer
at Commerce West:
$ out -info
comm 200 CSO Print Server v3.2 (22 Aug 14:20). Say
your request. Information about dest 'comm': 100 One of a
family of medium-speed impact printers at RJE sites. 100
Special options [defaults] that are recognized by this driver: 100
-forms name Specify name of form to be loaded [STAN]. 100
Additional information: [output omitted]... $
|
Quitting Programs Properly
|
UNIX is a multitasking environment-you can
have multiple programs running at the same time, even though only
one can be displayed to the screen at a time. Each program or
command that is invoked on a UNIX system is called a process or
job, and is given a process number so the system can
keep track of what's going on. When a program is exited, or a
command is completed, it stops using system resources, such as
memory, and its process number is returned to the pool of numbers
used by the system.
|
Quitting,
Suspending and Interrupting Programs
|
All UNIX programs have a preferred way of quitting
or exiting, usually consisting of a key combination such as
<CONTROL>x (Pico), <SHIFT>q (nn),
or <CONTROL>d (nslookup) or a command such as
quit, exit, or bye. When a program is exited
in the preferred manner, all files are closed properly and the
program relinquishes its process number and system resources. You
should learn how to quit each program you run, and use that method
whenever possible.
Occasionally, you may find yourself unable to quit a program in
the preferred manner, or you may need to temporarily interrupt a
process in order to do something else. Most programs can be
temporarily suspended by typing <CONTROL>z.
When a program is suspended, it stops processing, but doesn't
actually close and quit; therefore, it continues to use system
memory. A suspended job can be resumed. Another key combination,
<CONTROL>c, interrupts a program permanently.
An interrupted program stops processing and using system memory,
but open files may not close properly, and any work in progress
may not be saved.
|
Killing
a Suspended Program
|
At some time you may need to suspend a program to
check on another program you have running, to engage in a talk
request, or to look up a word with oed2 (Oxford
English Dictionary) while editing a file. When you're finished
with the secondary task, you can tell the system to resume running
the suspended program. For instance, suppose you're editing a file
in vi when a friend sends you a talk request. You
can suspend your vi session to go to the UNIX prompt and
accept the request. While talk is displayed on your screen,
it is in the foreground, and vi is suspended.
When you're finished talking to your friend and you've quit
the talk session, you can type fg, which stands for
"foreground," to resume your vi session.
If two or more programs are
suspended concurrently, you need to specify the process number of
the program you want to resume. As previously stated, the system
assigns a process number to each program or command that is
started. You can review the processes you're running using the
command ps at the UNIX prompt. For example, if you're
running a small program you wrote, plus Pine and oed2, your
ps output might look something like this:
$ ps
PID TTY TIME CMD 1058 pts/33 0:02 ksh 3670 pts/33 0:00
my_program 4577 pts/33 0:00 oed2 5432 pts/33 0:00 pine 6022
pts/33 0:00 ps $
The output shows the three programs that are
running, plus your shell (ksh) and the ps command.
The process number for each is found in the column labeled PID.
To bring any one of these programs to the foreground, use the
command fg process_number. For example, if
you wanted to resume oed2, you would type fg 4577.
If
you're trying to log out of your account, and you get the system
message "there are stopped jobs," it means a suspended
program is running. In this instance, you should resume the
program and exit it in the preferred manner. If you cannot do this
because you don't know how to quit or because something is wrong
with the program, you can terminate the process with the kill
command (i.e., kill process_number). Before
killing a process, verify its process number with the ps
command. In the above example, if you wanted to terminate
oed2, you would type kill 4577.
Sometimes, a simple kill command may not work
(i.e., the ps output shows that the process is still
running). When this happens, you can add a signal (a
command modifier similar to an option) to your kill command.
The safest signal is 3 (i.e., kill -3process_number),
which tells the system to quit the process by closing all
open files and exiting. If 3 doesn't work, use the 9
signal (i.e., kill -9process_number),
which is the absolute kill command and has the same effect
as an interrupt. Only use kill -9 when nothing else works,
since files may not close properly and you may lose any work in
progress.
|
Changing Your Password
|
To keep your UNIX account secure, change your
password several times a year. You can change your password by
typing passwd at the UNIX prompt. The system will prompt
you to type your old password (to verify your identity), and to
type your new password twice. Below is the screen output produced
by changing passwords on students.uiuc.edu:
$ passwd Changing
Cluster password for joe Old password: (password
not shown) New password: (password not
shown) Re-enter new password: (password
not shown) Password changed successfully on
Cluster server. Cluster account data will be updated at
approximately 11:00 $
New passwords do not take effect immediately on the
CCSO UNIX clusters. If you change your password on the cluster,
log out, and then log in again immediately, you may need to use
your old password again. On other systems, however, passwords may
be updated immediately.
|
Logging Out
|
When you want to log out of your UNIX account,
simply type exit at the UNIX prompt (on some systems,
logout works also). Occasionally when you attempt to log
out, you may see a message saying "there are stopped jobs."
This simply means that you intentionally or unintentionally
suspended a program while you were working. You should either
resume the program and quit it properly, or, if this isn't
possible, use the ps command to see its process number and
then use the kill command to quit it as described earlier
in this section.
|
UNIX Command Quick
Reference
* (asterisk)
|
|
Wildcard character representing zero or more of any and all
adjacent characters in file or directory names.
|
.
|
|
Notation for "current
working directory."
|
..
|
|
Notation for "directory immediately above current
working directory"; used with cd and ls
commands.
|
~
|
|
Notation for absolute path of user's home directory.
|
~login
|
|
Absolute path of the home directory of the user specified by
Login.
|
cat
file_name
|
|
Concatenate (or display) the entire file specified to the
screen.
|
cat file_name1 file_name2 >
new_file
|
|
Combine two or more existing files into a new file.
|
cat file_name >> existing_file
|
|
Append one or more files to the end of an existing file.
|
chmod
mode file_name(s)
|
|
Change the read, write, or
execute permissions of a file or directory; mode consists of
who, opcode, and permission. Example: chmod
g+r file_name
Who Options
|
|
Opcode Options
|
|
Permissions
|
|
u user
|
|
+ add permission
|
|
r read
|
g group
|
|
- remove permission
|
|
w write
|
o other
|
|
= assign permission
|
|
x execute
|
a all of the above
|
|
|
|
|
|
|
|
cd
directory_name
|
|
Change to the specified directory; can take relative or
absolute path.
|
cp [-i]
old_file_name new_file_name
|
|
Create a duplicate of the file in the current working
directory. Options include i (interactive, prompt for y
or n before overwriting an existing file).
|
cp [-i] file_name directory_name
|
|
Create a duplicate of the file with the same name in the
directory specified. Options include i (interactive,
prompt for y or n before before overwriting an
existing file).
|
cp [-i] file_name directory/file_name
|
|
Create a duplicate of the file with a different name in the
directory specified. Options include i (interactive,
prompt for y or n before overwriting an existing
file).
|
ls [-al]
[file_name(s) or directory_name]
|
|
List the specified file(s),or all the files in the specified
directory. Options include a (list all, including dot
files) and l (long format).
|
mkdir
directory_name(s)
|
|
Make one or more new directories with the name(s) specified.
|
more
file_name
|
|
Display the specified file one screen at a time.
|
mv [-i]
old_file_name new_file_name
|
|
Rename the specified file. Options include i
(interactive, prompt for y or n before
overwriting an existing file).
|
mv [-i] old_directory_name new_directory_name
|
|
Rename the specified directory. Options include -i
(interactive, prompt for y or n before
overwriting an existing directory).
|
mv [-i] directory_name1 directory_name2
|
|
Move the first directory (and all files and subdirectories
it contains) to the second directory. Directory_name2
must already exist. Options include -i (interactive,
prompt for y or n before overwriting an existing
directory).
|
mv [-i] file_name directory_name
|
|
Move the specified file to the specified directory. Options
include -i (interactive, prompt for y or n
before overwriting an existing file).
|
out
-dest printer_name[-banner string
-bin value file_name
|
|
|
Print specified file to the specified printer. Options
include -bin value (specify a bin number
for printout storage), -banner string
specify a string to be printed in large print on the banner
page).
|
out -info printer_name
|
|
Display information about the specified output device.
|
printenv PATH
|
|
Print the preconfigured search path for your login to the
screen.
|
pwd
|
|
Print the name of the
current working directory to the screen.
|
quota -v
|
|
Return information about your quota limits ad current usage.
|
rm [-i]
file_name(s)
|
|
Remove the specified file(s). Options include -i
(interactive, prompt for y or n before removing).
|
rmdir
[-i] directory_name(s)
|
|
Remove the specified directory(s) which must be empty.
Options include -i (interactive, prompt for y or
n before removing).
|
|
|