Home » Linux Basics » 01 - An Introduction to Linux
1

A Linux Process

Understanding how Linux works

Figure 1a: Linux Processes
Figure 1a: Linux Processes

Any program or command currently running on the RAM memory of a computer is called a process. Linux is a multi-User system - many people may simultaneously sign in and run commands and applications on a computer running the Linux OS. Each user logs in through a terminal that provides an interface for the user - this terminal is a process in itself. Every program or command each user executes by typing a command on a terminal spawns a new process. The parent of such processes is the terminal on which the command was issued. Linux keeps track of the user each process belongs to, the terminal that issued the command, and resources (such as open files, a database and so on) that the process owns - these parameters constitute part of the process context. Every process that originates from a user is a child of another process and may spawn its own child processes. Only the 'init' process with the process ID (PID) 1 is not a child of another process. The init process has to do with system start-up and initialization.

Figure 1b: Typical Process Tree
Figure 1b: Typical Process Tree

When a user logs into a Linux system, the user obtains access to a command line interpreter or shell (typically 'bash' in Linux). This interpreter is similar to the DOS command window with a prompt like 'c:\'. Users may type in commands at the prompt on this interpreter (usually a '$' or '%'). As each shell is a process owned by the user, the system has at least n processes for n logged in users. Let"s say that a user wants to edit a file using the 'vi' editor. He would issue the command 'vi filename' at the shell prompt. The shell process remains; the new editor process becomes a child of the user's shell process. Figure 1b shows a typical process tree. Linux Systems are typically configured to start up the X Windows GUI with a few terminal emulators (into which commands may be typed) and other utilities like xclock. The 'init' process starts a shell; this shell runs the 'xinit' command to start X Windows. The 'xinit' process may spawn a couple of xterm terminal emulators, and other X applications like Xcalendar or Xclock.

In addition to user processes as mentioned above, processes started by the system that deal with memory management and task scheduling also run on the CPU. Other system processes deal with mail delivery, printing documents and so on. Such processes are referred to as daemons or background processes which run without user intervention. Normally, system processes run at a higher priority than user processes.

Users may also run programs on the background. When a user runs a program on the background, the shell does not wait for the program to finish before accepting a new command. A user may choose to relegate a program that takes a long time to execute to the background so that he or she can continue to work without having to wait for the program's execution to complete