MONITOR PROCESSES WITH PS

Linux offers you the ability to see exactly what's happening on your system with the ps command. With ps, you can see what programs are running, what their process IDs are, who started the programs, how long they've been running, etc.

A number of arguments tell the ps command what information to display. For instance, the argument aux tells ps to display all processes running on a terminal, including those of other users, to display it in a user-oriented format, and to display processes without a controlling terminal (i.e., those in the background). A typical output might look something like this:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 1 0.0 0.0 1412 80 ? S Apr29 0:04 init q

mailq 1862 0.0 0.0 1384 320 ? S Apr29 0:00 qmail-clean

root 1955 0.0 0.3 6868 2388 ? S Apr29 0:00 httpd-perl -f

apache 1962 0.0 0.1 6976 1472 ? S Apr29 0:00 httpd-perl -f

This shows the first running processes on the system (init is always first). Looking at our example, we can determine that the system was started or rebooted on April 29 by the START value. The TIME column displays how much CPU time the process has used, while the STAT column displays the current process state:

*R is a runnable process.

* D is in disk wait.

* T is traced or stopped.

* S is sleeping.

* Z is a zombie process.

Additional flags indicating process priority and swap status may be displayed as well. The %CPU and %MEM columns indicate the percentage of CPU and real memory the process is taking.