13.2 Displaying Processes
13.2.1 The ps command
The ps (process status) command is used to list the processes currently running on the system. This is normally done if a process is taking too long or appears to have stopped as indicated by a terminal window not responding or "hanging." By listing the processes, you can see the name of the command or program that initiated the process plus any child processes it may have spawned. By executing the ps command more than once, you can see if a process is still running by looking at the time for the process, which is the amount of CPU time the process is using. If the amount of time does not increase, then the process may have stopped. You can use the ps command to check the process ID (PID) of the process and then "kill" the process if it is taking too long or has stopped.

The output of the ps command will display the PID number and the command or program associated with it. The PID number is normally used to terminate a process. There are three main options with the ps command: -e (every process), -f (full listing) and -u (user).

Command Format:
ps [-options]

ps - The ps command by itself will display PID, TTY (terminal type), TIME (cpu time), and CMD (command that initiated the process) for only your processes running in the current shell. If you opened a terminal window under CDE, you will not see any of the other processes you have initiated.

ps -e - The ps command with the -e (every) option will display PID, TTY TIME, and CMD for all process running on the system.

ps -f - The ps command with the -f (full) option will show a listing of all information (UID, PID, PPID, C, STIME, TTY TIME and CMD) but only for those processes running under the current shell or terminal window.

ps -u userid - The ps command with the -u option will display PID, TTY TIME, and CMD for every processes running on the system for a particular user.

Figure shows the output of the basic ps command with no options. The ps -ef command will show every process on the system and all information available in a full listing. Because of the number of processes usually running on a system, it is useful to pipe the ps -ef command to more so that the output can be read a page at a time, as shown in the example in Figure . Note that root initiated the /etc/init daemon as process number 1. User aster with PID 1292 is running a Korn shell (-ksh) process from the console. User rose with PID 1400 is running a clock program under open windows. Figure describes the column headings from the ps -ef command. The controlling terminal for system daemons appears as a question mark (?). The word <defunct> will appear in the CMD column if a process is a zombie or defunct process. In addition, the CPU time may be a bit higher for a defunct process than for other processes.