Beginners Guide to understanding Unix
NOTICE: TO ALL CONCERNED Certain text files and messages contained on this site deal with activities and devices which would be in violation of various Federal, State, and local laws if actually carried out or constructed. The webmasters of this site do not advocate the breaking of any law. Our text files and message bases are for informational purposes only. We recommend that you contact your local law enforcement officials before undertaking any project based upon any information obtained from this or any other web site. We do not guarantee that any of the information contained on this system is correct, workable, or factual. We are not responsible for, nor do we assume any liability for, damages resulting from the use of any information on this site.
UNIX for Beginning Users
Developed by:
User Liaison Section, D-7131
Denver Office
[Name and Phone number deleted at authors
Request]
Revision Date: September 16, 1991
I. INTRODUCTION
A. Audience
This course is for individuals who will be using the UNIX
operating system on a Reclamation computer platform. It is
assumed that the student has a general understanding of data
processing concepts.
B. Course Objectives
Upon successful completion of this course the student will be
able to:
1. Demonstrate a knowledge of basic UNIX ideas.
2. Recognize the different types of files and the file
structure.
3. Log in and out of UNIX using an interactive terminal.
4. Change the password and be aware of other
responsibilities of owning an account.
5. Demonstrate a knowledge of where to get help.
6. Use the appropriate UNIX commands to display/print
files, copy/move files, change file access permissions,
create/delete directories, and change the current
working directory.
7. Transfer a file to another computer platform using File
Transfer Protocol (FTP). Use FTP commands to do the
following: initialize FTP, establish connection, local
computer commands, remote computer commands, close
connection, exit FTP, help command, and special
functions.
8. Use an editor to create files, input text,
insert/replace text, copy/move text, and exit/save
changes.
9. Use the mail utility to send/receive/delete messages
10. Use basic Annex commands to reestablish connection to a
disconnected process.
C. Course Handout Conventions
There are several conventions used in this handout for
consistency and easier interpretation:
1. Samples of actual terminal sessions are single-lined
boxed.
2. User entries are shown in bold print and are
underlined.
QUIT
3. All keyboard functions in the text will be bold.
(Ret) Backspace
Tab Ctrl-F6
Print (Shift-F7) Go to DOS (1)
NOTE: (Ret) indicates the Return or Enter key
located above the right Shift key.
4. Examples of user entries not showing the computer's
response are in dotted-lined boxes.
5. Command formats are double-lined boxed.
6. Three dots either in vertical or horizontal alignment
mean continuation or that data is missing from the
diagram.
??
? ?
? ?
? Multimax, Nanobus, and UMAX are trademarks of ?
? Encore Computer Corporation ?
? ?
? ?
? Annex is a trademark of XYLOGICS, Inc ?
? ?
? ?
? UNIX and Teletype are registered trademarks of ?
? AT&T Bell Laboratories ?
? ?
? ?
? Ethernet is a trademark of Xerox Corporation ?
? ?
? ?
? ?
??
1. BASIC UNIX IDEAS
The UNIX operating system is a set of programs that act as a link
between the computer and the user. The programs that allocate
the system resources and coordinate all the details of the
computer's internals is called the operating system or kernel.
Users communicate with the kernel through a program known as the
shell. The shell is a command line interpreter; it translates
commands entered by the user and converts them into a language
that is understood by the kernel.
Here is a basic block diagram of a UNIX system.
Spread Sheet Compilers
Calculators ?
? ?
V V
? The Shell ? Mail and
? ?<- Message
Inventory ? ? UNIX system kernel ? ? Facilities
Control --->? ? ? ? ?
Systems ? ? ? ? ? ?<- Interpreters
? ? ? Hardware ? ? ?
Formatters ->? ? ? ? ? ?<- DBMS
? ? ? ? ? ?
Calendar ? ? ? ? ? Word
Systems ---->? ? ? ?<- Processors
? ?
Editors ---->? ?<- FTP
The designers of UNIX used the following Maxims while writing the
new operating system.
1. Make each program do one thing well. These simple
programs would be called "tools."
2. Expect the output of every program to be the input to
another program.
3. Don't stop building new "tools" to do a job. The
library of tools should keep increasing.
1.1 The UNIX System
The main concept that unites all versions of UNIX is the
following four basics:
Kernel
The kernel is the heart of the operating system. It schedules
tasks and manages data storage. The user rarely interfaces with
the kernel directly. This is the memory resident portion of the
operating system.
Shell
The shell is the utility that processes your requests. When you
type in a command at your terminal, the shell interprets the
command and calls the program that you want. The shell will
support multiple users, multiple tasks, and multiple interfaces
to itself. The shell uses standard syntax for all commands.
There are two popular shells currently available, the BourneShell
(standard System V UNIX) and the CShell (BSD UNIX). Because
separate users can use different shells at the same time, the
system can appear different to different users. There is another
shell known as the KornShell (named after its designer), which is
popular with programmers. This ability to provide a customized
user interface is one of the most powerful features of UNIX.
Commands and Utilities
Separate utilities can be easily combined to customize function
and output. They are flexible, adaptable, portable, and modular.
They use pipes and filters. There are over 200 standard commands
plus numerous others provided through 3rd party software.
Files and Directories
The directory system supports a multilevel hierarchy. Files and
directories have access protection. Files and directories are
accessed through pathnames. Files support multiple name links.
Removable filesystems are also supported.
1.2 File Structure
All data in UNIX is organized into files. All files are
organized into directories. These directories are organized into
a tree-like structure called the filesystem. The following
diagram describes the top level organization of the UNIX
filesystem:
/
(root)
?
??
? ? ? ? ? ? ?
bin dev etc lib tmp usr users
These directories, in turn, are also organized hierarchically.
For example:
/
?
??
? ? ?
dev etc usr
? ? ?
?? ?? ?
? ? ? ? ? ? ?
dsk rmt init.d rc0.d mail adm spool
?
? ?
acct sa
In this example, dev, etc, usr, and adm are directories.
Directories contain other files or directories. Plain files
contain text or binary data and contain no information about
other files or directories.
Users can make use of this same structure to organize their
files.
For example:
/
?
??
? ? ?
bin users dev
?
?
? ?
bsmith sjones
? ?
? ? ? ? ?
memos progs physics chem history
? ? ? ? ?
? ?? ?? ? ??
? ? ? ? ? ? ? ? ? ?
mfg eng c f77 mods calcs forms notes loc anc
Every file has a name. A filename is composed of one to fourteen
characters. Although you can use almost any character in a
filename, you will avoid confusion if you choose characters from
the following list.
1. upper case letters [A-Z]
2. lower case letters [a-z]
3. numbers [0-9]
4. underscore [_]
5. period [.]
6. comma [,]
The only exception is the root directory, which always uses the
symbol /. No other directory or file can use this symbol.
Like children of one parent, no two files in the same directory
can have the same name. Files in different directories, like
children of different parents, can have the same name.
The filenames you choose should mean something. Too often, a
directory is filled with important files with names like foobar,
wombat, and junk. A meaningless name won't help you recall the
contents of a file. Use filenames that are descriptive of the
contents.
1.3 UNIX System Files
In order for you to have a basic understanding of the contents of
some of the system directories, here is a partial list of those
directories and what files they contain:
/bin This is where the executable files are located.
They are available to all user.
/dev These are device drivers.
/etc Supervisor directory commands, configuration
files, disk configuration files, reboot files,
valid user lists, groups, ethernet, hosts, where
to send critical messages.
/lib compiler libraries
/tmp scratch processes, editors, compilers, and
databases
/bsd Berkeley commands
/mnt empty, used for disks
/stand boot information
/lost+found orphans go here (look here after system crash)
/unix* executable, bootable kernel
This is not an exhaustive list of directories that contain system
information but it is intended to remove some of the mystery
behind these directories and the types of files they contain.
1.4 Command Line Syntax
Users enter commands at the shell prompt. The default
BourneShell prompt is the dollar sign ($). In general, the shell
expects to see the following syntax:
??
? Command Format: command options arguments ?
??
Command - This is the UNIX command. Sometimes the command
is representative of the function. For example,
the command to list the contents of a directory is
ls. The first and third letters of the word
"list" are used. Unfortunately, this is not
always the case.
Options - These are also known as flags. The common form
is:
-A
where A is the abbreviation of the optional
function of the command. For example, the command
ls lists the contents of a directory, while the
command ls -l provides a long listing and ls -C
provides output in columns. Several options can
be combined following one '-'; for example -CF, or
they can be entered separately as -C -F.
Arguments - These can be file names, user names, or qualifiers
to the command or one of its options.
Example:
.................................................................
. $ls -CF sjones .
.................................................................
The UNIX command is ls list contents of directory the dash (-)
indicates the options.
C = Multiple-column output with entries sorted down the
columns
F = Put a slash (/) after each filename if that file is a
directory and put an asterisk (*) after each filename
that is executable.
sjones = name of the directory to list (it can be a
relative or absolute pathname)
Example:
.................................................................
. $diff memo1 memo2 .
.................................................................
diff - differential file comparator command
memo1 - filename argument
memo2 - filename argument
This command will tell what lines must be changed in two files to
bring them into agreement.
Here is another example that doesn't fit the general syntax for
UNIX commands.
Example:
.................................................................
. $find . -atime +7 -print .
.................................................................
find - find files
. - the current working directory
-atime - True if the file has been accessed in n days (n is
the +7)
-print - always true; causes the current path name to be
printed
So, this command will give a listing of all files in your current
working directory that have been accessed in the past seven days.
Some commands have several options and/or arguments; while
others, like passwd and mail, are interactive and will prompt the
user for additional input.
1.5 Correcting Mistakes
Because the shell and most other utilities do not interpret the
command line (or other text) until you press the (Ret) key, you
can correct typing mistakes before you press (Ret). There are
two ways to correct typing mistakes. You can erase one character
at a time, or you can back up to the beginning of the command
line in one step. After you press (Ret), it is too late to make
a correction.
1.5.1 Erasing Characters
When entering characters from the keyboard, you can backspace up
to and over a mistake by pressing the erase key (#) one time for
each character you wish to delete. The # will appear on the
screen, and the character preceding it will be discounted.
Example:
.................................................................
. $ls phajne#y .
.................................................................
In this example, the e will be ignored and ls phajny is sent to
the Multimax. Multiple typos can be erased; simply press one #
for each character to be erased. The erase key will back up as
many characters as you wish, but it will not back up past the
beginning of the line.
1.5.2 Deleting an Entire Line
You can delete an entire line you are entering any time before
you press (Ret) by pressing the kill key (@). When you press the
@ (kill key), the cursor moves down to the next line and all the
way to the left. The shell doesn't give you another prompt, but
it is as though the cursor is following a prompt. The operating
system does not remove the line with the mistake but instead
ignores it. Now enter the command (or text) again from the
start.
1.5.3 Aborting Program Execution
Sometimes you may want to terminate a running program. UNIX
might be performing a listing that is too long to display on your
screen or for some other reason you want to terminate execution.
To terminate program execution press the Delete key. The
operating system sends a terminal interrupt signal to the shell.
When the shell receives this signal, it displays a prompt and
waits for another command.
1.5.4 Controlling Output to the Screen
There are several ways to control the flow of characters to the
screen as a result of executing a command. Such as:
Ctrl-S - This keyboard function command will suspend
the flow of characters to the screen as the
result of executing a command. The screen
will not continue until the keyboard function
to resume output is given.
Ctrl-Q - This keyboard function command will resume
the output to the screen.
Hold Screen - If your terminal has this key (i.e. VT200),
you can press it once to stop output to the
screen. To resume output to the screen,
press the key again.
Denver BOR MULTIMAX
Each BOR Multimax 310 has four 15 Megahertz National
Semiconductor 32-bit processors with 64 kilobytes of cache memory
rated at 2 million instructions per second (MIPS) for a total of
8 MIPS. The main memory consists of 32 megabytes (million bytes).
There can be a maximum of 14 disk drives. Each drive has a
capacity of 600 megabytes for a total capacity of 8.4 gigabytes
(a gigabyte is one thousand million bytes)
Connection to the Multimax is accomplished through one of several
methods. Access is made through TCP/IP based Annex terminal
servers. The two Annex II servers have 32 ports each and the
Annex I has 16 ports. The Annex II servers will allow up to 64
users access to the two Multimax computers. The Annex I is used
for access to the on-line printers. CDCnet and TELNET are other
ways to gain access to the Multimaxes.
Printouts are handled on a 600-line-per-minute line printer and a
10-page-per-minute laser printer. Each Multimax has a hardcopy
terminal and a CRT to serve as an operator console. There are two
tape drives capable of 1600 or 6250 bits per inch (bpi) on each
system. There is also a cassette tape drive.
Software available are FORTRAN, COBOL, C, and UNISOL (an
accounting package). The database management system is INGRES by
Relational Technology, Inc. PROCOMM+ will be the communication
interface with IBM PC's and compatibles. The operating system for
the Multimax is UMAX V. UMAX V is the name for the Encore
implementation of UNIX System V.
1.6 Logging on the Annex
This sample session shows how the login process is displayed on
the terminal screen and is uniform for all users. To bring the
standard menu onto the screen, press the Space Bar. If you are
using a PC, first start PROCOMM+. Then when you are in the
Terminal-Mode Screen, press the Space Bar; and the MICOM menu
will appear.
NOTE: Login procedures from the regions are included in the
back of this manual
Sample Session:
??
? WELCOME TO THE B.O.R. NETWORK P/S:B ?
? SYSTEMS PRESENTLY AVAILABLE ARE: ?
? ?
? **SYSTEM** **NAME** ?
? ?
? VAX 8300'S VAX ?
? CYBER/CDCNET F.E. CDC ?
? ENCORE/UNIX MAX ?
? OUT DIAL OD ?
? ?
? TO SELECT A SYSTEM, ENTER THE SYSTEM ?
? NAME AND CARRIAGE RETURN AT NEXT ?
? PROMPT. ?
? ?
? CHANNEL 08/061. ENTER RESOURCE MAX ?
? ?
??
MAX is the resource name you must enter to be connected to the
Annex, which is the Multimax front end processor. Some MICOM
menus might not have the MAX selection; in this case, enter MAX
to select the Annex. This is the same as if the menu showed the
option.
After entering MAX you will see something similar to the
following:
Sample Session:
??
? CONNECTED TO 06/011 ?
??
This indicates that you are connected to the port selector. Wait
two seconds, press (Ret) twice, and the annex prompt will appear
after a warning message.
Sample Session:
? ?
? Annex Command Line Interpreter * Copyright 1988 Xylogics, Inc. ?
? ?
? ***WARNING***Unauthorized access to U.S. Government computers ?
? is punishable by fine and/or imprisonment. ***WARNING*** ?
? annex: ?
1.7 Logging on the Multimax
To establish a connection between the Annex and the Multimax
enter the following command at the Annex prompt:
??
? Command Format: rlogin <host> ?
? ?
? host - name of the Multimax ?
??
The Denver Multimaxes have been assigned the names domax0 and
domax1. The names stand for the Denver Office Multimax System 0
and 1. The domax0 is used for production of Bureau-wide
applications. The domax1 is used for training and application
development and it is the one to use for exercises associated
with this course.
To enter domax1 type:
Sample Session:
??
? annex:rlogin domax1 ?
??
or
??
? annex:r domax1 ?
??
NOTE: Abbreviations are allowed for the Annex commands, the
only requirement is to type in enough characters to
make it unique.
When the Annex has opened communications with the selected host,
the following prompt will appear:
Sample Session:
??
? login: ?
??
To connect with the host, enter your login name at the prompt.
Your login name is assigned to you by the system administrator
and typically will be your first initial and last name, all one
word with no spaces. Only 8 characters are allowed for the
username so extra letters will be truncated.
Sample Session:
??
? login:rharding ?
??
Once the login name has been accepted, the next prompt will be
for the password. The following prompt will appear on the
screen.
Sample Session:
??
? Password: ?
??
Enter your password. For security reasons, the host will not
display your password as you type it.
Sample Session:
??
? Password: secret ?
??
Once you have entered the correct password. The login procedure
will continue and the following will appear on the monitor
screen.
Sample Session:
?
? UNIX System V Release ax.2.2o ns32332 ?
? domax1 ?
? Copyright ? 1984 AT&T ?
? All Rights Reserved ?
? ***WARNING***Unauthorized access to/use of this U.S. Government ?
? computer is punishable by fine and/or imprisonment. ***WARNING***?
? $ ?
?
At this point you are successfully signed on to the Multimax.
The dollar sign ($) is the default prompt for the BourneShell.
1.8 Logging Off the Multimax
At the shell prompt $, you can logout of the Multimax using one
of the following methods:
1. Enter the keyboard function command Ctrl-D.
2. Type the UNIX command exit.
Once you have entered the command to logout the following will
appear on the screen:
Sample Session:
??
? $exit ?
? CLI: Connection closed. ?
? annex: ?
??
Once you are back at the Annex prompt, you can establish another
connection or logout of the Annex.
1.9 Logging Off the Annex
When the Annex prompt (annex:) appears, you can enter the command
to logout of the Annex. The command to logout of the Annex is as
follows:
??
? Command Format: hangup ?
??
There is a 60 minute inactivity timeout programmed into the
Annex; however, it is a waste of resources if you don't enter
hangup. When you are finished with your session, be sure to enter
hangup at the annex: prompt.
If you don't type anything for 60 minutes, the Annex will log you
out of the system and display the following message:
Sample Session:
??
? *** Annex Port Reset Due to Inactivity Timeout *** ?
? ?
? Annex Command Line Interpreter ?
? DISCONNECTED ?
??
When the hangup command has been entered, the following will
appear on the screen:
Sample Session:
??
? annex: hangup ?
? ?
? Resetting line and disconnecting. ?
? ?
? ?
? Annex Command Line Interpreter * Copyright 1988 Xylogics ?
? annex: ?
? DISCONNECTED ?
??
1.10 Changing the Password
The following command will change the password.
??
? Command Format: passwd ?
??
You will be prompted to enter the existing password (this
question is skipped if you don't have a password). Next you will
be prompted to enter the new password. You will then be asked to
enter the new password again. This will verify that you have not
made a typographical error. If the two entries are the same, the
password will be changed. The new password must meet the
following criteria:
NOTE: Some of these items are configurable by the system
administrator and these reflect the settings for the Denver
Multimax only.
1. Each password must have at least six characters. Only
the first eight characters are significant.
2. Each password must contain at least two alphabetic
characters and at least one numeric or special
character. Alphabetic characters can be upper or lower
case.
3. Each password must differ from the login name and
any reverse or circular shift of that login name.
For comparison purposes, an upper case letter and
its corresponding lower case letter are
equivalent.
4. A new password must differ from the old by at
least three characters. For comparison purposes,
an upper case letter and its corresponding lower
case character are equivalent.
Passwords on the Multimax have a thirteen-week expiration period.
At the end of the thirteen weeks, you will be required to change
your password. Once you have changed the password, you cannot
change it again for two weeks. This prevents you from
immediately changing back to the old password and eliminates a
possible security violation. If you try to change the password
before two weeks have passed since the last change, a warning
message will be displayed.
Sample Session:
??
? $passwd ?
? Changing password for teacher ?
? Old password: secret ?
? Sorry: < 2 weeks since the last change ?
? $ ?
??
NOTE: This is about as friendly as UMAX will ever get.
Try to choose a password that is not easy for someone else to
guess. The increasing number of computer crimes involving thefts
all point to a need for protecting the system from unauthorized
access. Do not use words like your birthdate, telephone number,
spouse's name, child's name, etc. for passwords. Although you
may think passwords are an unnecessary nuisance, they are an
important way to strengthen the security of the computer system.
1.11 On-line Manual
The major source of on-line help is in the form of documentation
known as the on-line manual pages. The pages are divided into
eight sections. Section 1 contains entries for UMAX user
commands; the other sections describe administrative tools,
library functions, games, and internal system structure and
calls.
To gain access to the on-line manual pages enter the following
command:
??
? Command Format: man <command> ?
? ?
? command - the UNIX command you want information about ?
??
NOTE: The name 'man' stands for manual.
Example:
.................................................................
. $man ls .
.................................................................
This command will display the on-line manual pages for the ls
command.
The on-line manual pages entry begins with the command name and a
one line summary followed by a synopsis of the command line
syntax. Optional flags and arguments are enclosed by square
brackets []. A detailed description of the command and all of
its options and arguments follow the synopsis. The description
can include helpful examples. At the conclusion of the entry,
related files and commands are listed.
NOTE: Most on-line manual pages will fill more than one
screen. Be sure to control the output to your screen.
1.12 who and finger Commands
Once you have logged onto the Multimax, you can find out who is
logged on the system with the following commands:
??
? Command Format: who [options] ?
? ?
? options - see man pages for a complete list ?
? ?
??
The default output (no options) of the who command lists the
user's login name, terminal line, and the time that the user
logged in.
Sample Session:
??
? $who ?
? jwheeler ttyp0 Aug 15 10:26 ?
? mvlsdba rt02190 Aug 15 09:25 ?
? teacher rt020b0 Aug 15 11:07 ?
? eholderf rt021c0 Aug 15 11:03 ?
? dbowman rt01150 Aug 15 08:58 ?
? $ ?
??
Options will display other information about the users that are
currently logged onto the system. Some items available are the
amount of time that has elapsed since activity occurred on that
line, the process identifier (PID) of the login process,
comments, and exit information.
A UNIX command that provides a little more information about
users that are logged in the system is the finger command.
??
? Command Format: finger [options] [user1] ?
? ?
? options - see on line manual for complete list ?
? ?
? user1 - login name ?
??
The finger command with no options will list the login name, full
name, terminal name, write status (an asterisk (*) before the
terminal name indicates that write permission is denied), idle
time, login time, office location, and phone number (if known)
for each user that is currently logged in the system.
Sample Session:
??
? $finger ?
? Login Name TTY Idle When Office ?
? Jwheeler Jim Wheeler ttyp0 16 Wed 10:26 MP ?
? mvlsdba Motor Veh Lic rt02190 16 Wed 09:25 d7160 ?
? teacher Teacher Acct *rt020b0 Wed 11:07 ?
? eholderf Eileen Holder rt021c0 1 Wed 11:03 ?
? dbowman Dale Bowman rt01150 Wed 08:58 ?
? $ ?
??
Workshop 1
This workshop will reinforce your understanding of the ideas
presented in Chapter 1. Each student is to complete the entire
workshop.
DESK EXERCISES
1. What two organizations first developed UNIX?
2. In what high level programming language is UNIX written?
3. What are some characteristics of UNIX?
4. What is Encore Computer Corporations implementation of UNIX
called?
5. What part of UNIX controls the details of the computer's
internal operations?
6. What part of UNIX allows the user to communicate with the
computer?