Previous Table of Contents Next


Module 109
ps

DESCRIPTION

The external ps command is used to report process status. A process is a single task the computer is executing. When you execute a program such as cat, your shell spawns a new process (task). On UNIX there are multiple tasks waiting for execution. Each task is assigned a process ID (PID). Using the ps command you can display information about these various processes.

Without options the ps command reports the process ID, the associated tty, the cumulative execution time, and the command being executed. Various options to ps cause more detailed information to be retrieved and select certain processes to be reported.

COMMAND FORMAT

Following is the general format of the ps command.

     ps [ -acdefjl ] [ -g grplist ] [ -n name ] [ -p proclist ] \
        [ -s sesslist ] [ -t ttylist ] [ -u uidlist ]

BSD (Berkeley)
ps [ -acegklnsuvwxUn ] [ -ttty ] [ name ] [ core ]
ps [ -acegklnsuvwxUttty n ] [ name ] [ core ]
The n option must be last.

Options

The following list describes the options and their arguments that may be used to control how ps functions.

-a Displays information about all processes except process group leaders and processes not associated with a terminal.
-c Display information about scheduler priorities.
-d Displays information about all processes except group leaders.
-e Displays information about all processes currently in the system's process table. All active processes.
-f Displays a "full" listing of header information. The columns listed are:
UID PID PPID STIME TTY TIME COMMAND
See the Column Header section that follows for complete definitions of each column header. This option only changes the number of columns displayed. It does not determine which processes to list.
-j Display session IDs and process group IDs.
-l Displays a "long" listing of header information. The columns listed are:
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME COMMAND
See the Column Header section that follows for complete definitions of each column header. This command only changes the number of columns displayed. It does not determine which processes to list.
-g grplist Display only the processes whose process group leader's IDs are provided in the grplist. The list can be comma separated with no spaces or enclosed in quotes and space separated.
-n name Use the file name as an alternate system executable file in place of the default /unix executable. This is the bootable UNIX kernel file. This file contains the names and addresses of variables used in the system kernel. The ps command needs the information held in these variables. Using a different name allows you to obtain information from a previous version of the operating system that has been saved in a system crash file.
-p proclist Display only the processes whose process IDs are given in the proclist. The list can be comma separated with no spaces or enclosed in quotes and space separated.
-s sesslist Display information on all session leaders listed.
-t ttylist Displays only the processes associated with the terminals given in ttylist. Terminal names are the device's filename; for example, "tty05" or "co." If the name begins with "tty" then only the number is required. For example, "14" is interpreted as "tty14." The list can be comma separated with no spaces or enclosed in quotes and space separated.
-u uidlist Displays only the processes whose user ID (UID) or login name is given in uidlist. The UID is displayed in the ps listing unless you use the -f option; then the login name is displayed.
If no options are provided ps defaults to a minimal listing, displaying only processes associated with your terminal. The header columns displayed are:
PID TTY TIME COMMAND

BSD (Berkeley) options
The fields displayed by some ps options vary among BSD based vendors. The following provides information for the actual BSD implementation.
-a Display information about all other user's processes associated with terminals.
-c Display the internally stored command name, instead of the the command name from the process's address space. This is more reliable since the process can destroy the command arguments in its own address space.
-e Display the process's environment in addition to the arguments. The fields displayed are,
PID TT STAT TIME COMMAND
See the COLUMN HEADER section that follows for complete definitions of each column header. This command only changes the number of columns displayed. It does not determine which processes to list.
-g Display all processes. Normally ps only displays "interesting" processes. "Uninteresting" processes are process group leaders. Thus top level command interpreters (shells) and terminal monitoring processes (gettys) are eliminated.
-k Changes the default core file used by ps. The name is /vmcore instead of /dev/kmem and /dev/mem. The name must be the last arguement, core, on the command line.
-l Display a long listing. The following fields are displayed:
F UID PID PPID CP PRI NI ADDR SIZE RSS WCHAN STAT \ TT TIME COMMAND
See the Column Header section that follows for complete definitions of each column header. This command only changes the number of columns displayed. It does not determine which processes to list.
-n Converts certain fields to numeric output. The WCHAN output is converted to numbers in long listings. The USER field is converted to UID number fields in user listings.
-s Display the size of the kernel stack for each process. The SSIZ field is added to the output.
-ttty Displays processes whose controlling tty is tty. If the the tty is 03 then use -t03, if it is the console use -tco.
-u Display user related information. The fields are,
USER PID %CPU %MEM SZ RSS TT STAT TIME COMMAND
See the Column Header section that follows for complete definitions of each column header.
-v Display virtual memory attributes. The fields are,
PID TT STAT TIME SL RE PAGEIN SIZE RSS LIM TSIZ \ TRS %CPU %MEM COMMAND
See the Column Header section that follows for complete definitions of each column header.
-w Display output in 132 columns instead of 80. If -ww is given as an option, then an arbitrary output length is used to accommodate the length of the actual output.
-x Display all processes, even those not attached to terminals.
-U Update the private database used to store ps information. The ps -U command is often included in the /etc/rc file.
n Display only the process whose process is n. This option must be the last option on the command line.
If no options are provided ps defaults to a minimal listing, displaying only processes associated with your terminal. The header columns displayed are:
PID TT TIME STAT COMMAND

ARGUMENTS

The ps command has two possible arguments.

name The file containing the kernel's namelist.
core The name of the file containing the in-core memory image of the process. Usually /dev/mem or a file named "core."


Previous Table of Contents Next