Reports a snapshot of the status of currently running processes.

Description

On every UNIX-like operating system, the process status command (ps) displays information about active processes. Every operating system’s version of ps is slightly different, so consult your documentation for specific options.

  • Description
  • Syntax
  • Notes
  • Process Flags
  • Process State Codes
  • Obsolete Sort Keys
  • AIX Format Descriptors
  • Standard Format Specifiers
  • Environment Variables
  • Personality
  • Examples
  • Related commands
  • Linux commands help

This documentation describes a version of ps common to many distributions of Linux. It accepts several kinds of options:

  • UNIX options, which may be grouped and must be preceded by a dash ("-").
  • BSD options, which may be grouped and must not be used with a dash.
  • GNU long options, which are preceded by two dashes ("–").

Options of different types may be freely mixed, but might cause conflicts. There are some synonymous options, which are functionally identical, due to the many standards and compatible ps implementations.

Note that “ps -aux” is different than “ps aux”. The POSIX and UNIX standards require that “ps -aux” print all processes owned by a user named “x”, and printing all processes that would be selected by the -a option. If the user named “x” does not exist, ps may interpret the command as “ps aux” instead and print a warning. This behavior is intended to aid in the transitioning of legacy scripts, but it is subject to change, and thus should not be relied upon.

By default, ps selects all processes with the same effective user ID (euid=EUID) as the current user and associated with the same terminal as the invoker. It displays the process ID (pid=PID), the terminal associated with the process (tname=TTY), the cumulated CPU time in [DD-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD). Output is unsorted by default.

The use of BSD-style options adds process state (stat=STAT) to the default display and show the command arguments (args=COMMAND) instead of the executable name. You can override this with the PS_FORMAT environment variable. The use of BSD-style options also changes the process selection to include processes on other TTYs (terminals) that are owned by you; alternately, this may be described as setting the selection to be the set of all processes filtered to exclude processes owned by other users or not on a terminal. These effects are not considered when options are described as being “identical” below, so -M is considered identical to Z and so on.

Except as described below, process selection options are additive. The default selection is discarded, and then the selected processes are added to the set of processes to be displayed. A process is shown if it meets any of the given selection criteria.

Syntax

ps [options]

Options: Simple Process Selection

Options: Process Selection By List

These options accept a single argument in the form of a blank-separated or comma-separated list, and they can be used multiple times. For example:

ps -p “1 2” -p 3,4

…is a valid command.

Options which select processes by list are as follows:

Options: Output Format Control

These options are used to choose the information displayed by ps. The output may differ from version to version.

Options: Output Modifiers

Options: Thread Display

Options: Displaying Other Information

Notes

ps works by reading the virtual files in /proc. ps does not need to be setuid kmem or have any privileges to run. Do not give this ps any special permissions.

ps jaxkuid,-ppid,+pid

ps axk comm o comm,args

ps kstart_time -ef

  • $PS_SYSMAP$PS_SYSTEM_MAP/proc/*/wchan/boot/System.map-$(uname -r)/boot/System.map/lib/modules/$(uname -r)/System.map/usr/src/linux/System.map/System.map

This ps needs access to namelist data for proper WCHAN display. For kernels before 2.6, the System.map file must be installed.

CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process. This is not ideal, and it does not conform to the standards of ps. CPU usage is unlikely to add up to exactly 100%.

The SIZE and RSS fields don’t count some parts of a process including the page tables, kernel stack, struct thread_info, and struct task_struct. This is usually at least 20 KiB of memory that is always resident. SIZE is the virtual size of the process (code+data+stack).

Processes marked are dead processes (so-called “zombies”) that remain because their parent has not destroyed them properly. These processes are destroyed by init if the parent process exits.

If the length of the username is greater than the length of the display column, the numeric user ID is displayed instead.

Process flags

The sum of these values is displayed in the “F” column, which is provided by the flags output specifier:

Process state codes

Here are the different values that the s, stat and state output specifiers (header “STAT” or “S”) display to describe the state of a process:

For BSD formats and when the stat keyword is used, additional characters may be displayed:

Obsolete sort keys

These keys are used by the BSD O option (when it is used for sorting). The GNU –sort option doesn’t use these keys, but the specifiers described below in the standard format specifiers section. Note that the values used in sorting are the internal values ps uses and not the “cooked” values used in some of the output format fields (e.g., sorting on tty sorts into device number, not according to the terminal name displayed). Pipe ps output into the sort command if you want to sort the cooked values.

AIX format descriptors

ps supports AIX format descriptors, which work somewhat like the formatting codes of printf. For example, the normal default output can be produced with this:

ps -eo “%p %y %x %c”

AIX Format Descriptors are as follows:

Standard format specifiers

Here are the different keywords used to control the output format (e.g., with option -o) or to sort the selected processes with the GNU-style –sort option.

For example: “ps -eo pid,user,args –sort user”.

ps tries to recognize most of the keywords used in other implementations of ps.

The following user-defined format specifiers may contain spaces:

  • args
  • cmd
  • comm
  • command
  • fname
  • ucmd
  • ucomm
  • lstart
  • bsdstart
  • start

Some keywords may not be available for sorting.

Environment variables

The following environment variables could affect ps:

In general, it is a bad idea to set these variables. The one exception is CMD_ENV or PS_PERSONALITY, which could be set to Linux for normal systems. Without that setting, ps follows the useless and bad parts of the Unix98 standard.

Personality

The following “personalities” affect the output of ps:

Examples

To see every process running on the system, using the standard syntax:

ps -e

ps -ef

ps -eF

ps -ely

To see every process on the system, using BSD syntax:

ps ax

ps axu

To display a process tree:

ps -ejH

ps axjf

To get info about threads:

ps -eLf

ps axms

To get security info:

ps -eo euser,ruser,suser,fuser,f,comm,label

ps axZ

ps -eM

To see every process running as root (real and effective ID) in user format:

ps -U root -u root u

To see every process with a user-defined format:

ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm

ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm

ps -Ao pid,tt,user,fname,tmout,f,wchan

Print only the process IDs of syslogd, the syslog daemon:

ps -C syslogd -o pid=

Print only the name of process ID 15:

ps -p 15 -o comm=

bg — Resume a suspended program without bringing it to the foreground.free — Display the amount of free and used memory.fuser — Identify processes using files or sockets.kill — Send a signal to a process, affecting its behavior or killing it.killall — Kill processes by name.nice — Invoke a command with an altered scheduling priority.pagesize — Display the size of a page of memory in bytes.pgrep — Look up processes based on the name or other attributes.priocntrl — Display or set scheduling parameters of a processes under Solaris.pstree — Display processes in a tree format.top — Display a sortable, continually-updated list of processes.tty — Print the file name of the terminal connected to standard input.uptime — Display information about how long the system was running.who — Display information about how long the system was running.