|Lesson 2||Types of processes |
|Objective||Define the two main types of processes on a UNIX system |
Types of Processes
A UNIX process is a running program. All the useful work done
on the system is done by one sort of process or another. Processes come in various flavors. Some processes hide in the background,
carrying out infrastructure duties such as running print queues. Others, such as shell programs, interact with humans. Still others are started and stopped by user commands, and carry out specific tasks to serve users.
One important class of processes is the class of interactive processes. These are the processes that take input and generate output in
response to direct human interaction. Probably the most important type of interactive process is a shell program. Shell programs, such
as the Bourne Shell (/bin/sh), the Korn Shell (/bin/ksh), and the Bourne Again Shell (/bin/bash) are interactive processes that take
input from a terminal and execute user commands. Each time a user logs on, the login process starts a new login shell process for that
user. When the login shell terminates, the user is logged out.
Many commands also give rise to interactive processes. For example, the grep command starts a grep process, which reads some specified list of
files and generates output for human use. Similarly, the
ls command produces an ls process, which reads directories on disk
and generates human-readable output.
In general, interactive processes are associated with a terminal device, on which they may display their output and collect their
Many processes on a running UNIX system lurk in the background, unconnected to any terminal and generating no visible input or output.
These processes are called daemons. A daemon is a process that is not associated with any terminal and is dedicated to
handling a particular task. For example, daemon processes run the print queue and handle network infrastructure tasks. On systems
supporting a Web server, the Web server process itself is usually a daemon. Keeping daemons correctly configured and running properly
is an important element of UNIX system administration.
Files versus processes
Programs are stored in files; therefore, every program has an associated file. For example, the
grep command is a program
stored in the file /usr/bin/grep. As mentioned earlier, running the
grep command starts a grep process. It is important to
keep straight the distinction between the file /usr/bin/grep and a running grep process.
A process is a running program. Because UNIX is multitasking, a given program may be run more than once simultaneously. Each separate
invocation of the program gives rise to a new process, even though all these processes came from the same file.
shell: The shell is a program that interprets your commands and passes them to the operating system for further processing. You enter commands at the shell prompt (also called the system prompt or command prompt).
grep: The grep command searches the named input files for lines containing a match to the given pattern. By default, grep prints the matching lines. The grep command reads from standard input if no files are given or when a filename of - is encountered.
device: A device is a piece of hardware used by the system, such as hard drives, CD-ROMs, and so on. Devices are treated as a special type of file.