Linux "ps" Command Line Options and Examples
report a snapshot of the current processes.

ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the displayed information, use top(1) instead. This version of ps accepts several kinds of options: 1 UNIX options, which may be grouped and must be preceded by a dash.


Usage:

ps [options]






Command Line Options:

-A
Select all processes. Identical to -e.
ps -A ...
-d
Select all processes except session leaders.
ps -d ...
--deselect
Select all processes except those that fulfill the specified conditions (negates the selection).Identical to -N.
ps --deselect ...
-e
g Really all, even session leaders. This flag is obsolete and may be discontinued in a future release.It is normally implied by the a flag, and is only useful when operating in the sunos4 personality.
ps -e ...
-123
123 Identical to --pid 123.
ps -123 ...
-C
Select by command name. This selects the processes whose executable name is given in cmdlist.
ps -C ...
-G
Select by real group ID (RGID) or name. This selects the processes whose real group name or ID is inthe grplist list. The real group ID identifies the group of the user who created the process, seegetgid(2).
ps -G ...
-g
Select by session OR by effective group name. Selection by session is specified by many standards, butselection by effective group is the logical behavior that several other operating systems use. This pswill select by session when the list is completely numeric (as sessions are). Group ID numbers willwork only when some group names are also specified. See the -s and --group options.
ps -g ...
--Group
Select by real group ID (RGID) or name. Identical to -G.
ps --Group ...
--group
Select by effective group ID (EGID) or name. This selects the processes whose effective group name orID is in grplist. The effective group ID describes the group whose file access permissions are used bythe process (see getegid(2)). The -g option is often an alternative to --group.p pidlistSelect by process ID. Identical to -p and --pid.
ps --group ...
-p
Select by PID. This selects the processes whose process ID numbers appear in pidlist. Identical to pand --pid.
ps -p ...
--pid
Select by process ID. Identical to -p and p.
ps --pid ...
--ppid
Select by parent process ID. This selects the processes with a parent process ID in pidlist. That is,it selects processes that are children of those listed in pidlist.q pidlistSelect by process ID (quick mode). Identical to -q and --quick-pid.
ps --ppid ...
-q
Select by PID (quick mode). This selects the processes whose process ID numbers appear in pidlist.With this option ps reads the necessary info only for the pids listed in the pidlist and doesn't applyadditional filtering rules. The order of pids is unsorted and preserved. No additional selectionoptions, sorting and forest type listings are allowed in this mode. Identical to q and --quick-pid.
ps -q ...
--quick-pid
Select by process ID (quick mode). Identical to -q and q.
ps --quick-pid ...
-s
Select by session ID. This selects the processes with a session ID specified in sesslist.
ps -s ...
--sid
Select by session ID. Identical to -s.t ttylistSelect by tty. Nearly identical to -t and --tty, but can also be used with an empty ttylist toindicate the terminal associated with ps. Using the T option is considered cleaner than using t withan empty ttylist.
ps --sid ...
-t
Select by tty. This selects the processes associated with the terminals given in ttylist. Terminals(ttys, or screens for text output) can be specified in several forms: /dev/ttyS1, ttyS1, S1. A plain
ps -t ...
-"
may be used to select processes not attached to any terminal.
ps -" ...
--tty
Select by terminal. Identical to -t and t.U userlistSelect by effective user ID (EUID) or name. This selects the processes whose effective user name or IDis in userlist. The effective user ID describes the user whose file access permissions are used by theprocess (see geteuid(2)). Identical to -u and --user.
ps --tty ...
-U
Select by real user ID (RUID) or name. It selects the processes whose real user name or ID is in theuserlist list. The real user ID identifies the user who created the process, see getuid(2).
ps -U ...
-u
Select by effective user ID (EUID) or name. This selects the processes whose effective user name or IDis in userlist.The effective user ID describes the user whose file access permissions are used by the process (seegeteuid(2)). Identical to U and --user.
ps -u ...
--User
Select by real user ID (RUID) or name. Identical to -U.
ps --User ...
--user
Select by effective user ID (EUID) or name. Identical to -u and U.OUTPUT FORMAT CONTROLThese options are used to choose the information displayed by ps. The output may differ by personality.
ps --user ...
-c
Show different scheduler information for the -l option.
ps -c ...
--context
Display security context format (for SELinux).
ps --context ...
-F
Extra full format. See the -f option, which -F implies.
ps -F ...
--format
user-defined format. Identical to -o and o.j BSD job control format.
ps --format ...
-j
l Display BSD long format.
ps -j ...
-l
Long format. The -y option is often useful with this.
ps -l ...
-M
O formatis preloaded o (overloaded). The BSD O option can act like -O (user-defined output format with somecommon fields predefined) or can be used to specify sort order. Heuristics are used to determine thebehavior of this option. To ensure that the desired behavior is obtained (sorting or formatting),specify the option in some other way (e.g. with -O or --sort). When used as a formatting option, itis identical to -O, with the BSD personality.
ps -M ...
-O
Like -o, but preloaded with some default columns. Identical to -o pid,format,state,tname,time,commandor -o pid,format,tname,time,cmd, see -o below.o formatSpecify user-defined format. Identical to -o and --format.
ps -O ...
-o
User-defined format. format is a single argument in the form of a blank-separated or comma-separatedlist, which offers a way to specify individual output columns. The recognized keywords are describedin the STANDARD FORMAT SPECIFIERS section below. Headers may be renamed (ps -o pid,ruser=RealUser -ocomm=Command) as desired. If all column headers are empty (ps -o pid= -o comm=) then the header linewill not be output. Column width will increase as needed for wide headers; this may be used to widenup columns such as WCHAN (ps -o pid,wchan=WIDE-WCHAN-COLUMN -o comm). Explicit width control (ps opid,wchan:42,cmd) is offered too. The behavior of ps -o pid=X,comm=Y varies with personality; output maybe one column named "X,comm=Y" or two columns named "X" and "Y". Use multiple -o options when indoubt. Use the PS_FORMAT environment variable to specify a default as desired; DefSysV and DefBSD aremacros that may be used to choose the default UNIX or BSD columns.s Display signal format.u Display user-oriented format.v Display virtual memory format.X Register format.
ps -o ...
-y
Z Add a column of security data. Identical to -M (for SELinux).OUTPUT MODIFIERSc Show the true command name. This is derived from the name of the executable file, rather than from theargv value. Command arguments and any modifications to them are thus not shown. This optioneffectively turns the args format keyword into the comm format keyword; it is useful with the -f formatoption and with the various BSD-style format options, which all normally display the command arguments.See the -f option, the format keyword args, and the format keyword comm.
ps -y ...
--cols
Set screen width.
ps --cols ...
--columns
Set screen width.
ps --columns ...
--cumulative
Include some dead child process data (as a sum with the parent).e Show the environment after the command.f ASCII art process hierarchy (forest).
ps --cumulative ...
--forest
ASCII art process tree.h No header. (or, one header per screen in the BSD personality). The h option is problematic. StandardBSD ps uses this option to print a header on each page of output, but older Linux ps uses this optionto totally disable the header. This version of ps follows the Linux usage of not printing the headerunless the BSD personality has been selected, in which case it prints a header on each page of output.Regardless of the current personality, you can use the long options --headers and --no-headers toenable printing headers each page or disable headers entirely, respectively.
ps --forest ...
-H
Show process hierarchy (forest).
ps -H ...
--headers
Repeat header lines, one per page of output.k spec Specify sorting order. Sorting syntax is [+|-]key[,[+|-]key[,...]]. Choose a multi-letter key fromthe STANDARD FORMAT SPECIFIERS section. The "+" is optional since default direction is increasingnumerical or lexicographic order. Identical to --sort.Examples:ps jaxkuid,-ppid,+pidps axk comm o comm,argsps kstart_time -ef
ps --headers ...
--lines
Set screen height.n Numeric output for WCHAN and USER (including all types of UID and GID).
ps --lines ...
--no-headers
Print no header line at all. --no-heading is an alias for this option.O orderSorting order (overloaded). The BSD O option can act like -O (user-defined output format with somecommon fields predefined) or can be used to specify sort order. Heuristics are used to determine thebehavior of this option. To ensure that the desired behavior is obtained (sorting or formatting),specify the option in some other way (e.g. with -O or --sort).For sorting, obsolete BSD O option syntax is O[+|-]k1[,[+|-]k2[,...]]. It orders the processes listingaccording to the multilevel sort specified by the sequence of one-letter short keys k1,k2, ...described in the OBSOLETE SORT KEYS section below. The "+" is currently optional, merely re-iteratingthe default direction on a key, but may help to distinguish an O sort from an O format. The "-"reverses direction only on the key it precedes.
ps --no-headers ...
--rows
Set screen height.S Sum up some information, such as CPU usage, from dead child processes into their parent. This isuseful for examining a system where a parent process repeatedly forks off short-lived children to dowork.
ps --rows ...
--sort
Specify sorting order. Sorting syntax is [+|-]key[,[+|-]key[,...]]. Choose a multi-letter key fromthe STANDARD FORMAT SPECIFIERS section. The "+" is optional since default direction is increasingnumerical or lexicographic order. Identical to k. For example: ps jax --sort=uid,-ppid,+pidw Wide output. Use this option twice for unlimited width.
ps --sort ...
-w
Wide output. Use this option twice for unlimited width.
ps -w ...
--width
Set screen width.THREAD DISPLAYH Show threads as if they were processes.
ps --width ...
-L
m Show threads after processes.
ps -L ...
-m
Show threads after processes.
ps -m ...
-T
OTHER INFORMATION
ps -T ...
--help
Print a help message. The section argument can be one of simple, list, output, threads, misc or all.The argument can be shortened to one of the underlined letters as in: s|l|o|t|m|a.
ps --help ...
--info
L List all format specifiers.V Print the procps-ng version.
ps --info ...
-V
Print the procps-ng version.
ps -V ...
--version
Print the procps-ng version.NOTESThis ps works by reading the virtual files in /proc. This ps does not need to be setuid kmem or have anyprivileges to run. Do not give this ps any special permissions.CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of aprocess. This is not ideal, and it does not conform to the standards that ps otherwise conforms to. CPUusage 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, structthread_info, and struct task_struct. This is usually at least 20 KiB of memory that is always resident. SIZEis the virtual size of the process (code+data+stack).Processes marked <defunct> are dead processes (so-called "zombies") that remain because their parent has notdestroyed them properly. These processes will be destroyed by init(8) if the parent process exits.If the length of the username is greater than the length of the display column, the username will betruncated. See the -o and -O formatting options to customize length.Commands options such as ps -aux are not recommended as it is a confusion of two different standards.According to the POSIX and UNIX standards, the above command asks to display all processes with a TTY(generally the commands users are running) plus all processes owned by a user named "x". If that user doesn'texist, then ps will assume you really meant "ps aux".PROCESS FLAGSThe sum of these values is displayed in the "F" column, which is provided by the flags output specifier:1 forked but didn't exec4 used super-user privilegesPROCESS STATE CODESHere are the different values that the s, stat and state output specifiers (header "STAT" or "S") will displayto describe the state of a process:D uninterruptible sleep (usually IO)R running or runnable (on run queue)S interruptible sleep (waiting for an event to complete)T stopped by job control signalt stopped by debugger during the tracingW paging (not valid since the 2.6.xx kernel)X dead (should never be seen)Z defunct ("zombie") process, terminated but not reaped by its parentFor BSD formats and when the stat keyword is used, additional characters may be displayed:< high-priority (not nice to other users)N low-priority (nice to other users)L has pages locked into memory (for real-time and custom IO)s is a session leaderl is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)+ is in the foreground process groupOBSOLETE SORT KEYSThese keys are used by the BSD O option (when it is used for sorting). The GNU --sort option doesn't usethese keys, but the specifiers described below in the STANDARD FORMAT SPECIFIERS section. Note that thevalues used in sorting are the internal values ps uses and not the "cooked" values used in some of the outputformat fields (e.g. sorting on tty will sort into device number, not according to the terminal namedisplayed). Pipe ps output into the sort(1) command if you want to sort the cooked values.KEY LONG DESCRIPTIONc cmd simple name of executableC pcpu cpu utilizationf flags flags as in long format F fieldg pgrp process group IDG tpgid controlling tty process group IDj cutime cumulative user timeJ cstime cumulative system timek utime user timem min_flt number of minor page faultsM maj_flt number of major page faultsn cmin_flt cumulative minor page faultsN cmaj_flt cumulative major page faultso session session IDp pid process IDP ppid parent process IDr rss resident set sizeR resident resident pagess size memory size in kilobytesS share amount of shared pagest tty the device number of the controlling ttyT start_time time process was startedU uid user ID numberu user user namev vsize total VM size in KiBy priority kernel scheduling priorityAIX FORMAT DESCRIPTORSThis ps supports AIX format descriptors, which work somewhat like the formatting codes of printf(1) andprintf(3). For example, the normal default output can be produced with this: ps -eo "%p %y %x %c". TheNORMAL codes are described in the next section.CODE NORMAL HEADER%C pcpu %CPU%G group GROUP%P ppid PPID%U user USER%a args COMMAND%c comm COMMAND%g rgroup RGROUP%n nice NI%p pid PID%r pgid PGID%t etime ELAPSED%u ruser RUSER%x time TIME%y tty TTY%z vsz VSZSTANDARD FORMAT SPECIFIERSHere are the different keywords that may be used to control the output format (e.g. with option -o) or to sortthe selected processes with the GNU-style --sort option.For example: ps -eo pid,user,args --sort userThis version of 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.CODE HEADER DESCRIPTION%cpu %CPU cpu utilization of the process in "##.#" format. Currently, it is the CPU time useddivided by the time the process has been running (cputime/realtime ratio), expressed asa percentage. It will not add up to 100% unless you are lucky. (alias pcpu).%mem %MEM ratio of the process's resident set size to the physical memory on the machine,expressed as a percentage. (alias pmem).args COMMAND command with all its arguments as a string. Modifications to the arguments may be shown.The output in this column may contain spaces. A process marked <defunct> is partlydead, waiting to be fully destroyed by its parent. Sometimes the process args will beunavailable; when this happens, ps will instead print the executable name in brackets.(alias cmd, command). See also the comm format keyword, the -f option, and the coption.When specified last, this column will extend to the edge of the display. If ps can notdetermine display width, as when output is redirected (piped) into a file or anothercommand, the output width is undefined (it may be 80, unlimited, determined by the TERMvariable, and so on). The COLUMNS environment variable or --cols option may be used toexactly determine the width in this case. The w or -w option may be also be used toadjust width.blocked BLOCKED mask of the blocked signals, see signal(7). According to the width of the field, a 32or 64-bit mask in hexadecimal format is displayed. (alias sig_block, sigmask).bsdstart START time the command started. If the process was started less than 24 hours ago, the outputformat is " HH:MM", else it is " Mmm:SS" (where Mmm is the three letters of the month).See also lstart, start, start_time, and stime.bsdtime TIME accumulated cpu time, user + system. The display format is usually "MMM:SS", but can beshifted to the right if the process used more than 999 minutes of cpu time.c C processor utilization. Currently, this is the integer value of the percent usage overthe lifetime of the process. (see %cpu).caught CAUGHT mask of the caught signals, see signal(7). According to the width of the field, a 32 or64 bits mask in hexadecimal format is displayed. (alias sig_catch, sigcatch).cgname CGNAME display name of control groups to which the process belongs.cgroup CGROUP display control groups to which the process belongs.class CLS scheduling class of the process. (alias policy, cls). Field's possible values are:
ps --version ...
-
TS SCHED_OTHERFF SCHED_FIFORR SCHED_RRB SCHED_BATCHISO SCHED_ISOIDL SCHED_IDLE? unknown valuecls CLS scheduling class of the process. (alias policy, cls). Field's possible values are:
ps - ...