![]() |
Linux is a true multi-tasking operating system, This means that it can run more than one task at a time on behalf of the user. In Linux terminology each of the multiple tasks is called a process. Each of these processes is running independantly, with it's own allocated resources. One of the first processes that the kernel spawns upon startup is the getty process, which listens for and responds to, a login. Each time you ask the shell to run a command, it forks a seperate process.
If you create a shell pipeline with the | operarator, each command component is a seperate process. The comand line $ cat thisfile | sort will generate two processes, one for each command. These processes communicate through the pipe. Some commands are internal to the shell and don't create any new processes.
A major purpose of the kernel is to provide control and support of the many programs that might want to use Central Processing Unit (CPU) at any one time. Several programs, or users may request access to the CPU at the same time. The kernel must grant access to only one application at a time. A process executes for only a short time, and then control passes to another process. This is why multi-tasking operating systems like Linux are called time sharing systems.
X is a process, which then in turn forks a new process when you call another program, or open an xterm. If you call a command in the xterm, this again forks another process, the command you asked to execute. This forking means that a new program is begun, with it's own process id (PID), while the calling program continues, ready to execute more commands from the user.
The ps command is used to see what processes are running. Output from the command typically looks something like this.
# ps
PID TTY STAT TIME COMMAND
639 p2 R 0:00 ps
16910 2 S 0:00 (mingetty)
17076 3 SW 0:00 (mingetty)
17077 4 SW 0:00 (mingetty)
17078 5 SW 0:00 (mingetty)
17079 6 SW 0:00 (mingetty)
26549 1 S 0:00 xterm -sb
28490 1 S 0:00 xterm -sb
28496 p2 S 0:00 su -
28497 p2 S 0:00 -bashThe output of the ps command is interpreted as follows: