Reference

ps(1)

process status

NAME

ps – process status

SYNOPSIS

ps [--libxo] [-AaCcdefHhjlmrSTuvwXxZ] [-O fmt] [-o fmt] [-D up | down | both] [-G gid[,gid...]] [-J jid[,jid...]] [-M core] [-N system] [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]

ps [--libxo] -L

DESCRIPTION

The ps utility displays information about a selection of processes. Its traditional text style output consists of a header line followed by one line of information per selected process, or possibly multiple ones if using -H (one per lightweight-process). Other output styles can be requested via --libxo.

By default, only the processes of the calling user, determined by matching their effective user ID with that of the ps process, that have controlling terminals are shown. A different set of processes can be selected for display by using combinations of the -A, -a, -D, -G, -J, -p, -T, -t, -U, -X, and -x options. Except for options -X and -x, as soon as one of them appears, it inhibits the default process selection, i.e., the calling user's processes are shown only on request. If more than one of these (with same exceptions) appear, ps will select processes as soon as they are matched by at least one of them (inclusive OR). The -X option can be independently used to further filter the listed processes to only those that have a controlling terminal( except for those selected by -p). Its opposite, -x, forcefully removes that filter. If none of -X and -x is specified, the implied default behavior is that of -X unless using another option whose description explicitly says that -x is implied.

For each selected process, the default displayed information consists of the process' ID, controlling terminal, state, CPU time (including both user and system time) and associated command( see the documentation for the command keyword below). This information can be tweaked using two groups of options which can be combined as needed. First, options -o and -O add columns with data corresponding to the explicitly passed keywords. Available keywords are documented in the KEYWORDS section below. They can be listed using option -L. Second, options -j, -l, -u, and -v designate specific predefined groups of columns, also called canned displays. Appearance of any of these options inhibits the default display, replacing it all with the requested columns, and in the order options are passed. The individual columns requested via a canned display option that have the same keyword or an alias to that of some column added by an earlier canned display option, or by an explicit -O or -o option anywhere on the command line, are suppressed. This automatic removal of duplicate data in canned displays is useful for slightly tweaking these displays and/or combining multiple ones without having to rebuild variants from scratch, e.g., using only -o options.

Output information lines are by default sorted first by controlling terminal, then by process ID, and then, if -H has been specified, by lightweight-process (thread) ID. The -m, -r, -u, and -v options will change the sort order. If more than one sorting option was given, then the selected processes will be sorted by the last sorting option which was specified.

If the traditional text output (the default) is used, the default output width is that requested by the COLUMNS environment variable if present, else the line width of the terminal associated to the ps process, if any. In all other situations, the output width is unlimited. See also the -w option and the BUGS section.

For backwards compatibility, ps attempts to interpret any positional argument as a process ID, as if specified by the -p option. Failure to do so will trigger an error. ps also accepts the old-style BSD options, whose format and effect are left undocumented on purpose.

The options are as follows:

--libxo

Generate output via libxo(3) in a selection of different human and machine readable formats. See xo_options(7) for details on command line arguments. The default is the traditional text style output.

-A

Display information about all processes in the system. Using this option is strictly equivalent to specifying both -a and -x. Please see their description for more information.

-a

Display information about all users' processes. It does not, however, list all processes( see -A and -x). If the security.bsd.see_other_uids sysctl is set to zero, this option is honored only if the real user ID of the ps process is 0.

-C

Change the way the CPU percentage is calculated by using a “raw” CPU calculation that ignores “resident” time (this normally has no effect).

-c

Change the “command” column output to just contain the executable name, rather than the full command line.

-D

Expand the list of selected processes based on the process tree. “UP” will add the ancestor processes, “DOWN” will add the descendant processes, and “BOTH” will add both the ancestor and the descendant processes. -D does not imply -d, but works well with it.

-d

Arrange processes into descendancy order and prefix each command with indentation text showing sibling and parent/child relationships as a tree. If either of the -m and -r options are also used, they control how sibling processes are sorted relative to each other. Note that this option has no effect if the last column does not have comm, command or ucomm as its keyword.

-e

Display the environment as well.

-f

Indicates to print the full command and arguments in command columns. This is the default behavior on FreeBSD. See -c to turn it off.

-G

Display information about processes whose real group ID matches the specified group IDs or names. Implies -x by default.

-H

Show all of the threads associated with each process.

-h

Repeat the information header as often as necessary to guarantee one header per page of information.

-J

Display information about processes which match the specified jail IDs. This may be either the jid or name of the jail. Use -J 0 to request display of host processes. Implies -x by default.

-j

Print information associated with the following keywords: user, pid, ppid, pgid, sid, jobc, state, tt, time, and command.

-L

List the set of keywords available for the -O and -o options.

-l

Display information associated with the following keywords: uid, pid, ppid, cpu, pri, nice, vsz, rss, mwchan, state, tt, time, and command.

-M

Extract values associated with the name list from the specified core instead of the currently running system.

-m

Sort by memory usage, instead of the combination of controlling terminal and process ID.

-N

Extract the name list from the specified system instead of the default, which is the kernel image the system has booted from.

-O

Save passed columns in a separate list that in the end is grafted just after the display's first occurrence of the process ID column as specified by other options, or the default display if there is none. If the display prepared by other options does not include a process ID column, the list is inserted at start of the display. Further occurrences of -O append to the to-be-grafted list of columns. This option takes a space- or comma-separated list of keywords. The last keyword in the list may be appended with an equals sign (‘=’) as explained for option -o and with the same effect.

-o

Display information associated with the space- or comma-separated list of keywords specified. The last keyword in the list may be appended with an equals sign (‘=’) and a string that spans the rest of the argument, and can contain space and comma characters. This causes the printed header to use the specified string instead of the standard header. Multiple keywords may also be given in the form of more than one -o option. So the header texts for multiple keywords can be changed. If all keywords have empty header texts, no header line is written.

-p

Display information about processes which match the specified process IDs. Processes selected by this option are not subject to being filtered by -X.

-r

Sort by current CPU usage, instead of the combination of controlling terminal and process ID.

-S

Change the way the process times, namely cputime, systime, and usertime, are calculated by summing all exited children to their parent process.

-T

Display information about processes attached to the device associated with the standard input.

-t

Display information about processes attached to the specified terminal devices. Full pathnames, as well as abbreviations (see explanation of the tt keyword) can be specified. Implies -x by default.

-U

Display information about processes whose real user ID matches the specified user IDs or names. Implies -x by default.

-u

Display information associated with the following keywords: user, pid, %cpu, %mem, vsz, rss, tt, state, start, time, and command. The -u option implies the -r option.

-v

Display information associated with the following keywords: pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz, %cpu, %mem, and command. The -v option implies the -m option.

-w

Use at least 131 columns to display information. If -w is specified more than once, ps will use as many columns as necessary. Please see the preamble of this manual page for how the output width is initially determined. In particular, if the initial output width is unlimited, specifying -w has no effect. Please also consult the BUGS section.

-X

When displaying processes selected by other options, skip any processes which do not have a controlling terminal, except for those selected through -p. This is the default behaviour, unless using another option whose description explicitly says that -x is implied.

-x

When displaying processes selected by other options, include processes which do not have a controlling terminal. This option has the opposite behavior to that of -X. If both -X and -x are specified, ps will obey the last occurrence.

-Z

Add mac(4) label to the list of keywords for which ps will display information.

KEYWORDS

The following is a complete list of the available keywords and their meanings. Several of them have aliases (keywords which are synonyms). Detailed descriptions for some of them can be found after this list.

%cpu

percentage CPU usage (alias pcpu)

%mem

percentage memory usage (alias pmem)

acflag

accounting flag (alias acflg)

args

command and arguments

class

login class

comm

command

command

command and arguments

cow

number of copy-on-write faults

cpu

The processor number on which the process is executing (visible only on SMP systems).

dsiz

data size in KiB

emul

system-call emulation environment (ABI)

etime

elapsed running time, format“[days-][hours:] minutes:seconds”

etimes

elapsed running time, in decimal integer seconds

fib

default FIB number, see setfib(1)

flags

the process flags, in hexadecimal (alias f)

flags2

the additional set of process flags, in hexadecimal (alias f2)

gid

effective group ID (alias egid)

group

group name (from egid) (alias egroup)

inblk

total blocks read (alias inblock)

jail

jail name

jid

jail ID

jobc

job control count

ktrace

tracing flags

label

MAC label

lim

memoryuse limit

lockname

lock currently blocked on (as a symbolic name)

logname

login name of user who started the session

lstart

time started

lwp

thread (light-weight process) ID (alias tid)

majflt

total page faults

minflt

total page reclaims

msgrcv

total messages received (reads from pipes/sockets)

msgsnd

total messages sent (writes on pipes/sockets)

mwchan

wait channel or lock currently blocked on

nice

nice value (alias ni)

nivcsw

total involuntary context switches

nlwp

number of threads (light-weight processes) tied to a process

nsigs

total signals taken (alias nsignals)

nswap

total swaps in/out

nvcsw

total voluntary context switches

nwchan

wait channel (as an address)

oublk

total blocks written (alias oublock)

paddr

process pointer

pagein

pageins (same as majflt)

pgid

process group number

pid

process ID

ppid

parent process ID

pri

scheduling priority

re

core residency time (in seconds; 127 = infinity)

rgid

real group ID

rgroup

group name (from rgid)

rss

resident set size in KiB

rtprio

realtime priority (see rtprio(1))

ruid

real user ID

ruser

user name (from ruid)

sid

session ID

sig

pending signals (alias pending)

sigcatch

caught signals (alias caught)

sigignore

ignored signals (alias ignored)

sigmask

blocked signals (alias blocked)

sl

sleep time (in seconds; 127 = infinity)

ssiz

stack size in KiB

start

time started

state

symbolic process state (alias stat)

svgid

saved gid from a setgid executable

svuid

saved UID from a setuid executable

systime

accumulated system CPU time

tdaddr

thread address

tdname

thread name

tdev

control terminal device number

time

accumulated CPU time, user + system (alias cputime)

tpgid

control terminal process group ID

tracer

tracer process ID

tsid

control terminal session ID

tsiz

text size in KiB

tt

control terminal name (two letter abbreviation)

tty

full name of control terminal

ucomm

process name used for accounting

uid

effective user ID (alias euid)

upr

scheduling priority on return from system call (alias usrpri)

uprocp

process pointer

user

user name (from UID)

usertime

accumulated user CPU time

vmaddr

vmspace pointer

vsz

virtual size in KiB (alias vsize)

wchan

wait channel (as a symbolic name)

xstat

exit or stop status (valid only for stopped or zombie process)

Some of these keywords are further specified as follows:

%cpu

The CPU utilization of the process; this is a decaying average over up to a minute of previous (real) time. Since the time base over which this is computed varies (since processes may be very young) it is possible for the sum of all %cpu fields to exceed 100%.

%mem

The percentage of real memory used by this process.

class

Login class associated with the process.

command

The printed command and arguments are determined as follows. A process that has exited and has a parent that has not yet waited for the process (in other words, a zombie) is listed as “<defunct>.” If the arguments cannot be located( usually because they have not been set, as is the case for system processes and/or kernel threads), the command name is printed within square brackets. The ps utility first tries to obtain the arguments cached by the kernel( if they were shorter than the value of the kern.ps_arg_cache_limit sysctl). The process can change the arguments shown with setproctitle(3). Otherwise, ps makes an educated guess as to the file name and arguments given when the process was created by examining memory or the swap area. The method is inherently somewhat unreliable and in any event a process is entitled to destroy this information. The ucomm keyword (accounting) can, however, be depended on. If the arguments are unavailable or do not agree with the ucomm keyword, the value for the ucomm keyword is appended to the arguments in parentheses.

flags

The flags associated with the process as in the include file ⟨sys/proc.h⟩:

P_ADVLOCK0x00000001Process may hold a POSIX advisory lock
P_CONTROLT0x00000002Has a controlling terminal
P_KPROC0x00000004Kernel process
P_PPWAIT0x00000010Parent is waiting for child to exec/exit
P_PROFIL0x00000020Has started profiling
P_STOPPROF0x00000040Has thread in requesting to stop prof
P_HADTHREADS0x00000080Has had threads (no cleanup shortcuts)
P_SUGID0x00000100Had set id privileges since last exec
P_SYSTEM0x00000200System proc: no sigs, stats or swapping
P_SINGLE_EXIT0x00000400Threads suspending should exit, not wait
P_TRACED0x00000800Debugged process being traced
P_WAITED0x00001000Someone is waiting for us
P_WEXIT0x00002000Working on exiting
P_EXEC0x00004000Process called exec
P_WKILLED0x00008000Killed, shall go to kernel/user boundary ASAP
P_CONTINUED0x00010000Proc has continued from a stopped state
P_STOPPED_SIG0x00020000Stopped due to SIGSTOP/SIGTSTP
P_STOPPED_TRACE0x00040000Stopped because of tracing
P_STOPPED_SINGLE0x00080000Only one thread can continue
P_PROTECTED0x00100000Do not kill on memory overcommit
P_SIGEVENT0x00200000Process pending signals changed
P_SINGLE_BOUNDARY0x00400000Threads should suspend at user boundary
P_HWPMC0x00800000Process is using HWPMCs
P_JAILED0x01000000Process is in jail
P_TOTAL_STOP0x02000000Stopped for system suspend
P_INEXEC0x04000000Process is in execve(2)
P_STATCHILD0x08000000Child process stopped or exited
P_INMEM0x10000000Always set, unused
P_PPTRACE0x80000000Vforked child issued ptrace(PT_TRACEME)
flags2

The flags kept in p_flag2 associated with the process as in the include file ⟨sys/proc.h⟩:

P2_INHERIT_PROTECTED0x00000001New children get P_PROTECTED
P2_NOTRACE0x00000002ptrace(2) attach or coredumps
P2_NOTRACE_EXEC0x00000004Keep P2_NOPTRACE on execve(2)
P2_AST_SU0x00000008Handles SU ast for kthreads
P2_PTRACE_FSTP0x00000010SIGSTOP from PT_ATTACH not yet handled
P2_TRAPCAP0x00000020SIGTRAP on ENOTCAPABLE
P2_ASLR_ENABLE0x00000040Force enable ASLR
P2_ASLR_DISABLE0x00000080Force disable ASLR
P2_ASLR_IGNSTART0x00000100Enable ASLR to consume sbrk area
P2_PROTMAX_ENABLE0x00000200Force enable implied PROT_MAX
P2_PROTMAX_DISABLE0x00000400Force disable implied PROT_MAX
P2_STKGAP_DISABLE0x00000800Disable stack gap for MAP_STACK
P2_STKGAP_DISABLE_EXEC0x00001000Stack gap disabled after exec
P2_ITSTOPPED0x00002000itimers stopped (as part of process stop)
P2_PTRACEREQ0x00004000Active ptrace req
P2_NO_NEW_PRIVS0x00008000Ignore setuid on exec
P2_WXORX_DISABLE0x00010000WX mappings enabled
P2_WXORX_ENABLE_EXEC0x00020000WxorX enabled after exec
P2_WEXIT0x00040000Internal exit early state
P2_REAPKILLED0x00080000REAP_KILL pass handled the process
P2_MEMBAR_PRIVE0x00100000membarrier private expedited registered
P2_MEMBAR_PRIVE_SYNCORE0x00200000membarrier private expedited sync core registered
P2_MEMBAR_GLOBE0x00400000membar global expedited registered
label

The MAC label of the process.

lim

The soft limit on memory used, specified via a call to setrlimit(2).

lstart

The exact time the command started, using the ‘%c’ format described in strftime(3).

lockname

The name of the lock that the process is currently blocked on. If the name is invalid or unknown, then “???” is displayed.

logname

The login name associated with the session the process is in (see getlogin(2)).

mwchan

The event name if the process is blocked normally, or the lock name if the process is blocked on a lock. See the wchan and lockname keywords for details.

nice

The process scheduling increment (see setpriority(2)).

rss

the real memory (resident set) size of the process in KiB.

start

The time the command started. If the command started less than 24 hours ago, the start time is displayed using the “%H:%M” format described in strftime(3). If the command started less than 7 days ago, the start time is displayed using the “%a%H” format. Otherwise, the start time is displayed using the “%e%b%y” format.

sig

The bitmask of signals pending in the process queue if the -H option has not been specified, else the per-thread queue of pending signals.

state

The state is given by a sequence of characters, for example, “RWNA”. The first character indicates the run state of the process:

D

Marks a process in disk (or other short term, uninterruptible) wait.

I

Marks a process that is idle (sleeping for longer than about 20 seconds).

L

Marks a process that is waiting to acquire a lock.

R

Marks a runnable process.

S

Marks a process that is sleeping for less than about 20 seconds.

T

Marks a stopped process.

W

Marks an idle interrupt thread.

Z

Marks a dead process (a “zombie”).

Additional characters after these, if any, indicate additional state information:

+

The process is in the foreground process group of its control terminal.

<

The process has raised CPU scheduling priority.

C

The process is in capsicum(4) capability mode.

E

The process is trying to exit.

J

Marks a process which is in jail(2). The hostname of the prison can be found in /proc/⟨pid⟩/status.

L

The process has pages locked in core (for example, for raw I/O).

N

The process has reduced CPU scheduling priority (see setpriority(2)).

s

The process is a session leader.

V

The process' parent is suspended during a vfork(2), waiting for the process to exec or exit.

X

The process is being traced or debugged.

tt

An abbreviation for the pathname of the controlling terminal, if any. The abbreviation consists of the three letters following /dev/tty, or, for pseudo-terminals, the corresponding entry in /dev/pts. This is followed by a ‘-’ if the process can no longer reach that controlling terminal (i.e., it has been revoked). A ‘-’ without a preceding two letter abbreviation or pseudo-terminal device number indicates a process which never had a controlling terminal. The full pathname of the controlling terminal is available via the tty keyword.

wchan

The event (an address in the system) on which a process waits. When printed numerically, the initial part of the address is trimmed off and the result is printed in hex, for example, 0x80324000 prints as 324000.

ENVIRONMENT

The following environment variables affect the execution of ps:

COLUMNS

If set, specifies the user's preferred output width in column positions. Only affects the traditional text style output. Please see the preamble of this manual page on how the final output width is determined.

FILES

/boot/kernel/kernel

default system namelist

EXIT STATUS

The ps utility exits 0 on success, and >0 if an error occurs.

EXAMPLES

Display information on all system processes:

$ ps -auxw

SEE ALSO

kill(1), pgrep(1), pkill(1), procstat(1), w(1), kvm(3), libxo(3), strftime(3), mac(4), procfs(4), xo_options(7), pstat(8), sysctl(8), mutex(9)

STANDARDS

For historical reasons, the ps utility under FreeBSD supports a different set of options from what is described by IEEE Std 1003.1-2024 (“POSIX.1”) and what is supported on non-BSD operating systems.

In particular, and contrary to this implementation, POSIX specifies that option -d should serve to select all processes except session leaders, option -e to select all processes( equivalently to -A), and option -u to select processes by effective user ID.

However, options -A, -a, -G, -l, -o, -p, -U, and -t behave as prescribed by IEEE Std 1003.1-2024 (“POSIX.1”). Options -f and -w currently do not, but may be changed to in the future.

POSIX's option -g, to select processes having the specified processes as their session leader, is not implemented. However, other UNIX systems that provide this functionality do so via option -s instead, reserving -g to query by group leaders.

HISTORY

The ps command appeared in Version 3 AT&T UNIX in section 8 of the manual.

BUGS

Since ps cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact.

ps currently does not correctly limit the output width, and in most cases does not limit it at all when it should. Regardless of the target width, requested columns are always all printed and with widths allowing to entirely print their longest values, except for columns with keyword command or args that are not last in the display (they are truncated to 16 bytes), and for the last column in the display if its keyword requests textual information of variable length, such as the command, jail, and user keywords do. This considerably limits the effects and usefulness of the terminal width on the output, and consequently that of the COLUMNS environment variable and the -w option (if specified only once).

The ps utility does not correctly display argument lists containing multibyte characters.

History

--libxo since FreeBSD 11.0-RELEASE; -A since FreeBSD 14.3-RELEASE; -D since FreeBSD 14.0-RELEASE; -G since FreeBSD 5.3-RELEASE; -H since FreeBSD 5.2-RELEASE; -J since FreeBSD 10.1-RELEASE; -U since FreeBSD 2.1.5-RELEASE; -X since FreeBSD 5.3-RELEASE; -Z since FreeBSD 5.0-RELEASE; -c since FreeBSD 2.2.2-RELEASE; -d since FreeBSD 7.3-RELEASE; -f since FreeBSD 2.2.6-RELEASE.

-W until FreeBSD 4.5-RELEASE.