A process is a single program running in its own virtual address space. Using this definition, everything running under Linux is a process. The process is a running instance of a program. Linux is a multitasking operating system, which means that more than one process can be active at once.
PS can show you the running processes on your system in different ways. Several types of processes are involved with the Linux operating system.
Each has its own special features and attributes:
An interactive process is a process initiated from (and controlled by) a shell. Interactive processes may be in foreground or background.
A batch process is a process that is not associated with a terminal but is submitted to a queue to be executed sequentially.
A daemon process is a process that runs in the background until it’s required. This kind of processes is usually initiated when Linux boots.
Process state codes
Here are the different values that the s, stat and state output specifiers
(header “STAT” or “S”) will display to describe the state of a process.
- D Uninterruptible sleep (usually IO) a blocked state. The process waits for a hardware condition and cannot handle any signal
- R Running Process is either running or ready to run
- S Interruptible sleep (waiting for an event to complete) a Blocked state of a process and waiting for an event or signal from another process
- T Stopped, either by a job control signal or because it is being traced Process is stopped or halted and can be restarted by some other process
- X dead (should never be seen)
- Z Defunct (“zombie”) process, terminated but not reaped by its parent process terminated, but the information is still there in the process table.
The easiest method of finding out which processes are running on your system is to use the ps (process status) command. The ps command is available to all system users, as well as root, although the output changes a little depending on whether you are logged in as root when you issue the command.
When you are logged in as a normal system user (not root) and issue the ps command by itself, it displays information about every process you are running.
The following output is an example of what you might see:
root@ssgeorge:~# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 5816 2040 ? Ss May30 0:00 /sbin/init
root 2 0.0 0.0 0 0 ? S May30 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S May30 0:01 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S May30 0:00 [migration/0]
root 5 0.0 0.0 0 0 ? S May30 0:00 [watchdog/0]
root 6 0.0 0.0 0 0 ? S May30 0:00 [migration/1]
The output of the ps command is always organized in columns. The first column is labeled PID, which means process identification number. The PID is a number that Linux assigns to each process to help in handling all processes.
PIDs start at zero and increment by one for each process being run, up to some system determined number (such as 65,564). When Linux reaches the highest number, it starts numbering from the lowest number again, skipping the numbers used by active processes. Usually, the lowest number processes are the system kernel and daemons, which start when Linux boots and remain active as long as Linux is running.
To manipulate processes (to terminate them, for example), you must use the PID. The TTY column in the ps command output shows you which terminal the process was started from. If you are logged in as a user, this column usually lists your terminal or console window. If you are running on multiple console windows, you see all the processes you started in every displayed window.
The STAT column in the ps command output shows you the current status of the process. The two most common entries in the STAT column are S for sleeping and R for running. A sleeping process is one that isn’t currently active. A running process is one that is currently executing on the CPU. Processes may switch between sleeping and running many times every second. The TIME column shows the total amount of system (CPU) time used by the process so far. These numbers tend to be very small for most processes, as they require only a short time to complete. The numbers under the TIME column are a total of the CPU time, not the amount of time the process has been alive.
Finally, the NAME column contains the name of the process you are running. This name is usually the command you entered, although some commands start-up other processes. These processes are called child processes, and they show up in the ps output as though you had entered them as commands.
As a general convention, login shells have a hyphen placed before their name (such as bash in the preceding output) to help you distinguish the startup shell from any shells you may have started afterward. Any other shells that appear in the output don’t have the hyphen in front of the name, as the following example shows:
PID TTY STAT TIME COMMAND
46 v01 S 0:01 bash
75 v01 S 0:00 phksh
96 v01 R 0:00 bash
123 v01 R 0:00 ps
This example shows that the user’s startup shell is bash (PID 46) and that the user started up the Korn shell (pdksh, PID 75) and another Bourne shell (bash, PID 96) afterward. Notice also that the process status, ps, appears in this output (and the previous one) because it is running when you issued the command.
The ps command always appears in the output.
If you require help, contact SupportPRO Server Admin