ps - report process status
ps [-aA][-defl][-G grouplist][-o format]...[-p proclist][-t termlist] [-U userlist][-g grouplist][-n namelist][-u userlist]
The ps utility writes information about processes, subject to having the appropriate privileges to obtain information about those processes.
By default, ps selects all processes with the same effective user ID as the current user and the same controlling terminal as the invoker.
The ps utility supports the XBD specification, Utility Syntax Guidelines .
The following options are supported:
- Write information for all processes associated with terminals. Implementations may omit session leaders from this list.
- Write information for all processes.
- Write information for all processes, except session leaders.
- Write information for all processes (equivalent to -A).
- Generate a full listing. (See the STDOUT section for the contents of a full listing.)
- -g grouplist
- Write information for processes whose session leaders are given in grouplist. The grouplist must be a single argument in the form of a blank- or comma-separated list.
- -G grouplist
- Write information for processes whose real group ID numbers are given in grouplist. The grouplist must be a single argument in the form of a blank- or comma-separated list.
- Generate a long listing. (See the STDOUT section for the contents of a long listing.)
- -n namelist
- Specify the name of an alternative system namelist file in place of the default. The name of the default file and the format of a namelist file are unspecified.
- -o format
- Write information according to the format specification given in format. This is fully described in the STDOUT section. Multiple -o options can be specified; the format specification will be interpreted as the space-character-separated concatenation of all the format option-arguments.
- -p proclist
- Write information for processes whose process ID numbers are given in proclist. The proclist must be a single argument in the form of a blank- or comma-separated list.
- -t termlist
- Write information for processes associated with terminals given in termlist. The termlist must be a single argument in the form of a blank- or comma-separated list. Terminal identifiers must be given in one of two forms: the device's filename (for example, tty04) or, if the device's filename starts with tty, just the identifier following the characters tty (for example, 04).
- -u userlist
- Write information for processes whose user ID numbers or login names are given in userlist. The userlist must be a single argument in the form of a blank- or comma-separated list. In the listing, the numerical user ID will be written unless the -f option is used, in which case the login name will be written.
- -U userlist
- Write information for processes whose real user ID numbers or login names are given in userlist. The userlist must be a single argument in the form of a blank- or comma-separated list.
With the exception of -o format, all of the options shown are used to select processes. If any are specified, the default list will be ignored and ps will select the processes represented by the inclusive OR of all the selection-criteria options.
The following environment variables affect the execution of ps:
- Override the system-selected horizontal screen size, used to determine the number of text columns to display. See the XBD specification, Environment Variables for valid values and results when it is unset or null.
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
- Determine the format and contents of the date and time strings displayed.
When the -o option is not specified, the standard output format is as follows. The column headings and descriptions of the columns in a ps listing are given below. The precise meanings of these fields are implementation-dependent. The letters f and l (below) indicate the option ( full or long) that causes the corresponding heading to appear; all means that the heading always appears. Note that these two options determine only what information is provided for a process; they do not determine which processes will be listed.
F (l) Flags (octal and additive) associated with the process. S (l) The state of the process. UID (f,l) The user ID number of the process owner; the login name is printed under the -f option. PID (all) The process ID of the process; it is possible to kill a process if this datum is known. PPID (f,l) The process ID of the parent process. C (f,l) Processor utilisation for scheduling. PRI (l) The priority of the process; higher numbers mean lower priority. NI (l) Nice value; used in priority computation. ADDR (l) The address of the process. SZ (l) The size in blocks of the core image of the process. WCHAN (l) The event for which the process is waiting or sleeping; if blank, the process is running. STIME (f) Starting time of the process. TTY (all) The controlling terminal for the process. TIME (all) The cumulative execution time for the process. CMD (all) The command name; the full command name and its arguments are written under the -f option.
A process that has exited and has a parent, but has not yet been waited for by the parent, is marked defunct.
Under the option -f, ps tries to determine the command name and arguments given when the process was created by examining memory or the swap area. Failing this, the command name, as it would appear without the option -f, is written in square brackets.
The -o option allows the output format to be specified under user control.
The format specification must be a list of names presented as a single argument, blank- or comma-separated. Each variable has a default header. The default header can be overridden by appending an equals sign and the new text of the header. The rest of the characters in the argument will be used as the header text. The fields specified will be written in the order specified on the command line, and should be arranged in columns in the output. The field widths will be selected by the system to be at least as wide as the header text (default or overridden value). If the header text is null, such as -o user=, the field width will be at least as wide as the default header text. If all header text fields are null, no header line will be written.
The following names are recognised in the POSIX locale:
- The real user ID of the process. This will be the textual user ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
- The effective user ID of the process. This will be the textual user ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
- The real group ID of the process. This will be the textual group ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
- The effective group ID of the process. This will be the textual group ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
- The decimal value of the process ID.
- The decimal value of the parent process ID.
- The decimal value of the process group ID.
- The ratio of CPU time used recently to CPU time available in the same period, expressed as a percentage. The meaning of "recently" in this context is unspecified. The CPU time available is determined in an unspecified manner.
- The size of the process in (virtual) memory in kilobytes as a decimal integer.
- The decimal value of the system scheduling priority of the process. See nice.
- In the POSIX locale, the elapsed time since the process was started, in the form:where dd will represent the number of days, hh the number of hours, mm the number of minutes, and ss the number of seconds. The dd field will be a decimal integer. The hh, mm and ss fields will be two-digit decimal integers padded on the left with zeros.
- In the POSIX locale, the cumulative CPU time of the process in the form:The dd, hh, mm and ss fields will be as described in the etime specifier.
- The name of the controlling terminal of the process (if any) in the same format used by the who utility.
- The name of the command being executed (argv value) as a string.
- The command with all its arguments as a string. The implementation may truncate this value to the field width; it is implementation-dependent whether any further truncation occurs. It is unspecified whether the string represented is a version of the argument list as it was passed to the command when it started, or is a version of the arguments as they may have been modified by the application. Applications cannot depend on being able to modify their argument list and having that modification be reflected in the output of ps.
Any field need not be meaningful in all implementations. In such a case a hyphen (-) should be output in place of the field value.
Only comm and args are allowed to contain blank characters; all others are not. Any implementation-dependent variables will be specified in the system documentation along with the default header and indicating if the field may contain blank characters.
The following table specifies the default header to be used in the POSIX locale corresponding to each format specifier.
Format Specifier Default Header Format Specifier Default Header args COMMAND ppid PPID comm COMMAND rgroup RGROUP etime ELAPSED ruser RUSER group GROUP time TIME nice NI tty TT pcpu %CPU user USER pgid PGID vsz VSZ pid PID
Table: Variable Names and Default Headers in ps
Used only for diagnostic messages.
The following exit values are returned:
- Successful completion.
- An error occurred.
Things can change while ps is running; the snapshot it gives is only true for an instant, and might not be accurate by the time it is displayed.
The args format specifier is allowed to produce a truncated version of the command arguments. In some implementations, this information is no longer available when the ps utility is executed.
If the field width is too narrow to display a textual ID, the system may use a numeric version. Normally, the system would be expected to choose large enough field widths, but if a large number of fields were selected to write, it might squeeze fields to their minimum sizes to fit on one line. One way to ensure adequate width for the textual IDs is to override the default header for a field to make it larger than most or all user or group names.
There is no special quoting mechanism for header text. The header text is the rest of the argument. If multiple header changes are needed, multiple -o options can be used, such as:
ps -o "user=User Name" -o pid=Process\ ID
On some systems, especially multi-level secure systems, ps may be severely restricted and produce information only about child processes owned by the user.
The command:writes at least the following in the POSIX locale:
ps -o user,pid,ppid=MOM -o args
The contents of the COMMAND field need not be the same in all implementations, due to possible truncation.
USER PID MOM COMMAND helene 34 12 ps -o uid,pid,ppid=MOM -o args
kill, nice, renice.