The Internet Encyclopedia (Volume 3)

(coco) #1

P1: JDW


UNIX WL040/Bidgoli-Vol III-Ch-41 August 13, 2003 17:26 Char Count= 0


500 UNIXOPERATINGSYSTEM

Login Processing
Because Unix is a multiuser environment, the system
needs to provide a way for multiple users to use the sys-
tem at the same time. This is done through a process
known as the “login process.” When a typical Unix sys-
tem starts up or “boots” (known as “bootstrapping”), the
masterboot sector of the primary hard disk partition is
read into the computer’s memory. It does several things,
but eventually the unix kernel is started (a program on the
disk called something like “unix” or “vmunix”). The kernel
sets up the system, including initializing process tables,
creating memory areas, and establishing certain buffers
and caches. After the kernel has established a sane state,
the kernel spawns (or “runs”) a program known as “init.”
The init program is important because it ensures that the
system is always ready in a particular “state.” The Unix
operating system has various states, including boot (ini-
tialization), restart, shutdown, single, and multiuser. The
normal state is multiuser, and when init begins this state,
another program known as a “getty” (spelled from “get”
and “tty” which is itself short for “teletype,” indicating
a terminal) is started on a particular terminal. The getty
process listens for activity from a terminal, and when a ter-
minal is connected, getty runs another program known as
“login,” which prompts a user to log in to the Unix system.
It is the login program that the average user first sees
as the interface to a Unix system. The user is prompted
to enter a username. Once it has been entered, the user
is prompted to enter his or her password. Once the user
has entered the username and password, the login process
examines these entries and compares the username and
password (encrypted) entered by the user with the infor-
mation that the superuser has entered for that user (users
are usually allowed to alter their password within certain
security constraints).
If the user has not entered the correct information, he
or she is advised of the failure and is not allowed access
to the system. At this point, the getty program spawns an-
other log-in program and the user is prompted to log in
again. If the user has entered the correct information, he
or she is “logged in,” and the log-in process spawns yet
another program, known as a command “shell,” which
prompts the user to enter commands to the system. The
shell interfaces the user with the rest of the Unix system
and prompts the user to enter new commands (a Unix
prompt usually is made up of a $ character or a % char-
acter, depending on which type of shell is being used).

The Home Directory
When a user is first logged on to a Unix system, the user’s
default directory is changed to a special directory known
as the user’s “home directory.” A typical Unix system has as
part of its directory hierarchy a directory called “home.”
Under this directory, all valid users on the system are given
their own directory, so one might see something such
as /home/bob and /home/sue, indicating both Bob and
Sue’s home directories. Users are usually given complete
permission over their home directories, so that they can
freely create new files there as needed. Users usually do
their work in their home directories (or subdirectories off
their home directory).

Online Help System
From the first release of AT&T Unix in November 1971,
the Unix system has provided an online help system, called
“manual pages.” Manual pages, or “man” pages for short,
are accessed by the “man” command. It is a cultural im-
perative that Unix commands come with their own man
pages. For example, if I wanted to find out how to run the
Unix “diff” command (which compares two files for sim-
ilarities and differences), I would execute the following
command:

man diff

I can also do a “keyword” search, by passing the -k flag
to man, and so the command

man -k write

would list all of the commands in the Unix system that
have something to do with “writing.” Each man page de-
tails the name of the command, the syntax for running the
command, and the various options for the command (op-
tions alter slightly the behavior of the command), and a
general description of the command along with any prob-
lems that exist with the command (known as “bugs”). Part
of the Unix culture was an honesty about its limitations,
and from the beginning program writers have detailed in
the man pages things that do not work quite right in their
programs.

Pipes and Filters
One of the seminal influences on early Unix development,
and one of the core reasons for Unix’s eventual success,
was the introduction of pipes and filters in AT&T System
V3. The third edition saw the inclusion of Doug McIlroy’s
long-fought argument for the usefulness of macros. Prior
to Unix, jobs were executed sequentially in batch mode,
and Job 2 had to wait until Job 1 had been completed until
it could begin processing. Essentially, Job 1 would write
out its data into a file, which would then become input for
Job 2, but only when Job 1 had completely finished writ-
ing the file. This prohibited concurrency, meaning that
it was impossible for two jobs to be running simultane-
ously, both operating at the same time on a continuum of
stream data. For a multitasking operating system, there-
fore, there needed to be a way for Job 1 to “send” its data
to Job 2as it was processing it,so that a stream of data
might be considered to bein process,and Job 1 and Job 2
could be simultaneously working on different sections of
the same data stream at the same time, with whatever
Job 2 was working on having already been processed by
Job 1. Strictly defined, this process was essentially han-
dled by connecting the output of one program (Job 1) to
the input of another program (Job 2). Thus, as Job 1 fin-
ishes processing some text, it hands that text off to Job 2,
which immediately begins processing the data, even as
Job 1 continues to work on the remaining input stream.
This pattern came to be known as pipes and filters, with
different jobs being known as filters, and the connection
of input and output as pipes.
Free download pdf