PS(1)

NAME
ps - display process status

SYNOPSIS
ps [[-]AacefHhjkLlmrSTuvwx] [-M core] [-N system] [-O fmt] [-o fmt] [-p pid] [-t tty] [-U user] [-W swap]

DESCRIPTION
The ps utility displays information about active processes. When given no options, ps prints information about processes of the current user that have a controlling terminal.

The information displayed is selected based on a set of keywords (and for even more control, see the -L, -O, and -o options). The default output format includes, for each process, the process's ID, controlling terminal, state, CPU time (including both user and system time), and associated command.

The options are as follows:

-A  Display information about processes for all users, including those without controlling terminals.

-a  Display information about processes for all users with controlling terminals.

-c  Do not display full command with arguments, but only the executable name. This may be somewhat confusing; for example, all sh(1) scripts will show as “sh”.

-e  Display the environment as well.

-f  Arrange processes into a tree. Each command is ordered and prefixed with indentation text showing sibling and parent/child relationships. If either of the -m and -r options are also used, they control how sibling processes are sorted relative to each other.

-H  Also display information about kernel visible threads.

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

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

-k  Also display information about kernel threads.

-L  List the set of available keywords. This option should not be specified with other options.

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

-M core
    Extract values associated with the name list from the specified core instead of the running kernel.

-m  Sort by memory usage, instead of by start time ID.

-N system
    Extract the name list from the specified system instead of the running kernel.

-O fmt
    Add the information associated with the space or comma separated list of keywords specified, after the process ID, in the default information display. Keywords may be appended with an equals sign (‘=’) and a string. This causes the printed header to use the specified string instead of the standard header.

-o fmt
    Display information associated with the space or comma separated list of keywords specified. Keywords may be appended with an equals sign (‘=’) and a string. This causes the printed header to use the specified string instead of the standard header.

-p pid
    Display information associated with the specified process ID.

-r  Sort by current CPU usage, instead of by start time ID.

-S  Change the way the process time is 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 tty
    Display information about processes attached to the specified terminal device.

-U user
    Only display processes belonging to username or UID user.

-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 swap
    When not using the running kernel, extract swap information from the specified file.

-w  Use 132 columns to display information, instead of the default, which is the window size. If the -w option is specified more than once, ps will use as many columns as necessary without regard for window size.

-x  Display information about processes without controlling terminals.

KEYWORDS
The following is a complete list of the available keywords and their meanings. Several of them have aliases, which are also noted.

%cpu
    Alias: pcpu. 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
    Alias: pmem. The percentage of real memory used by this process.

acflag
    Alias: acflg. Accounting flag.

command
    Alias: args. Command and arguments.

cpu Short-term CPU usage factor (for scheduling).

cpuid
    CPU ID (zero on single processor systems).

cwd Current working directory.

dsiz
    Data size, in Kilobytes.

etime
    Elapsed time since the process was started.

flags
    Alias: f. The thread flags (in hexadecimal), as defined in the include file <sys/proc.h>:

        P_INKTR           0x1 writing ktrace(2) record
        P_PROFPEND        0x2 this thread needs SIGPROF
        P_ALRMPEND        0x4 this thread needs SIGVTALRM
        P_SIGSUSPEND      0x8 need to restore before-suspend mask
        P_CANTSLEEP      0x10 this thread is not permitted to sleep
        P_SINTR          0x80 sleep is interruptible
        P_SYSTEM        0x200 system process: no sigs, stats, or
                              swapping
        P_TIMEOUT       0x400 timing out during sleep
        P_WEXIT        0x2000 working on exiting
        P_OWEUPC       0x8000 profiling sample needs recording
        P_SUSPSINGLE  0x80000 need to suspend for single threading
        P_THREAD    0x4000000 not the original thread
        P_SUSPSIG   0x8000000 stopped because of a signal
        P_CPUPEG   0x40000000 do not move to another cpu

gid Effective group.

group
    Text name of effective group ID.

inblk
    Alias: inblock. Total blocks read.

jobc
    Job control count.

ktrace
    Tracing flags.

ktracep
    Tracing vnode.

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

logname
    Alias: login. Login name of user who started the process.

lstart
    The exact time the command started, using the “%c” format described in strftime(3).

majflt
    Total page faults.

maxrss
    Maximum resident set size (in 1024 byte units).

minflt
    Total page reclaims.

msgrcv
    Total messages received (reads from pipes/sockets).

msgsnd
    Total messages sent (writes on pipes/sockets).

nice
    Alias: ni. The process scheduling increment (see setpriority(2)).

nivcsw
    Total involuntary context switches.

nsigs
    Alias: nsignals. Total signals taken.

nswap
    Total swaps in/out.

nvcsw
    Total voluntary context switches.

nwchan
    Wait channel (as an address).

oublk
    Alias: oublock. Total blocks written.

p_ru
    Resource usage (valid only for zombie processes).

paddr
    Swap address.

pagein
    Pageins (same as majflt).

pgid
    Process group number.

pid Process ID.

pledge
    Comma separated list of active pledge(2) promises.

ppid
    Parent process ID.

pri Scheduling priority.

procflags
    The process flags (in hexadecimal), as defined in the include file <sys/proc.h>:

        PS_CONTROLT            0x1 process has a controlling
                                   terminal
        PS_EXEC                0x2 process called exec(3)
        PS_INEXEC              0x4 process is doing an exec right
                                   now
        PS_EXITING             0x8 process is exiting
        PS_SUGID              0x10 process had set ID privileges
                                   since last exec
        PS_SUGIDEXEC          0x20 last exec(3) was set[ug]id
        PS_PPWAIT             0x40 parent is waiting for process
                                   to exec/exit
        PS_ISPWAIT            0x80 process is parent of PPWAIT
                                   child
        PS_PROFIL            0x100 process has started profiling
        PS_TRACED            0x200 process is being traced
        PS_WAITED            0x400 debugging process has waited
                                   for child
        PS_COREDUMP          0x800 busy coredumping
        PS_SINGLEEXIT       0x1000 other threads must die
        PS_SINGLEUNWIND     0x2000 other threads must unwind
        PS_NOZOMBIE         0x4000 pid 1 waits for me instead of
                                   dad
        PS_STOPPING         0x8000 just stopped, need to send
                                   SIGCHLD
        PS_SYSTEM          0x10000 No signals, stats or swapping
        PS_EMBRYO          0x20000 New process, not yet fledged
        PS_ZOMBIE          0x40000 Dead and ready to be waited for
        PS_NOBROADCASTKILL 0x80000 Process excluded from kill -1
        PS_PLEDGE         0x100000 process has called pledge(2)
        PS_EXECPLEDGE	0x00400000 has exec pledges
        PS_ORPHAN	0x00800000 process is on an orphan list
        PS_CHROOT	0x01000000 process is chrooted
        PS_CONTINUED    0x20000000 process continued from stopped state
                                   but has not been waited for yet
        PS_STOPPED      0x40000000 process is in stopped state

re  Core residency time (in seconds; 127 = infinity).

rgid
    Real group ID.

rgroup
    Text name of real group ID.

rlink
    Reverse link on run queue, or 0.

rss The real memory (resident set) size of the process (in 1024 byte units).

rtable
    Routing table.

ruid
    Real user ID.

ruser
    User name (from ruid).

sess
    Session ID (PID of session leader).

sig Alias: pending. Pending signals.

sigcatch
    Alias: caught. Caught signals.

sigignore
    Alias: ignored. Ignored signals.

sigmask
    Alias: blocked. Blocked signals.

sl  Sleep time (in seconds; 127 = infinity).

ssiz
    Stack size, in Kilobytes.

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

state
    Alias: stat. The state is given by a sequence of letters, for example, “RWN”. The first letter 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).
    R   Marks a runnable process.
    S   Marks a process that is sleeping for less than about 20 seconds.
    T   Marks a stopped process.
    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 controlling terminal.
        The process has a raised CPU scheduling priority (see setpriority(2)).
        The process has specified a soft limit on memory requirements and is currently exceeding that limit; such a process is (necessarily) not swapped.
    c   The process is chrooted.
    E   The process is trying to exit.
    K   The process is a kernel thread.
    N   The process has a reduced CPU scheduling priority.
    p   The process has called pledge(2).
    s   The process is a session leader.
    U   The process has unveiled, and unveil(2) is now locked.
    u   The process has unveiled, but not yet locked unveil(2) (could be a program error).
    V   The process is suspended during a vfork(2).
    X   The process is being traced or debugged.
    /n  On multiprocessor machines, specifies processor number n.

supgid
    Group IDs of supplementary groups.

supgrp
    Group names of supplementary groups.

svgid
    Saved GID from a setgid executable.

svuid
    Saved UID from a setuid executable.

tdev
    Controlling terminal device number.

tid Thread ID. Used together with -H.

time
    Alias: cputime. Accumulated CPU time, user + system.

tpgid
    Controlling terminal process group ID.

tsess
    Controlling terminal session pointer.

tsiz
    Text size, in Kilobytes.

tt  An abbreviation for the pathname of the controlling terminal, if any. The abbreviation consists of the two letters following “/dev/tty”, or, for the console, “co”. This is followed by a ‘-’ if the process can no longer reach that controlling terminal (i.e. it has been revoked).

tty Full name of controlling terminal.

ucomm
    Alias: comm. Name to be used for accounting.

uid Effective user ID.

upr Alias: usrpri. Scheduling priority on return from system call.

user
    User name (from uid).

vsz Alias: vsize. Virtual size, in Kilobytes.

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.

xstat
    Exit or stop status (valid only for stopped or zombie process).

ENVIRONMENT
The following environment variables affect the execution of ps:

COLUMNS
    If set to a positive integer, output is formatted to the given width in columns. Otherwise, ps defaults to the terminal width minus 1. If none of stdout, stderr, and stdin are a terminal, 79 columns are used.

LC_CTYPE
    The character encoding locale(1). It decides which byte sequences form characters, which characters are printable, and what their display width is. If unset or set to "C", "POSIX", or an unsupported value, only printable ASCII characters are printed. Tabs, newlines, non-printable ASCII characters, and non-ASCII bytes are encoded with vis(3). If UTF-8 output is enabled, valid characters that are not printable are replaced with the Unicode replacement character U+FFFD. These rules for example apply to command names, arguments, and environments and to directory, user, and group names.

TZ  The time zone to use when displaying dates. See environ(7) for more information.

FILES
/dev
    special files and device names
/var/db/kvm_bsd.db
    system namelist database
/var/run/dev.db
    /dev name database

EXIT STATUS

EXAMPLES
Display information on all system processes:

    $ ps -auxw

SEE ALSO
fstat(1), kill(1), netstat(1), pgrep(1), pkill(1), procmap(1), systat(1), top(1), w(1), kvm(3), strftime(3), dev_mkdb(8), iostat(8), pstat(8), vmstat(8)

STANDARDS
The ps utility is compliant with the p1003.1-2008 specification, except that the flag [-G] is unsupported and the flags [-ptU] support only single arguments, not lists.

The flags [-defglnu] are marked by p1003.1-2008 as being an X/Open System Interfaces option. Of these, [-dfgn] are not supported by this implementation of ps; behaviour for the flags [-elu] differs between this implementation and the X/Open System Interfaces option of p1003.1-2008.

The flags [-cfHhjkLMmNOrSTvWwx] are extensions to p1003.1-2008.

Only the following keywords are recognised by p1003.1-2008: args, comm, etime, group, nice, pcpu, pgid, pid, ppid, rgroup, ruser, time, tty, user, and vsz.

HISTORY
A ps command first appeared in AT&T UNIX.

CAVEATS
When printing using the command keyword, 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>”, and a process which is blocked while trying to exit is listed as “<exiting>”. 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, so the names cannot be depended on too much. The ucomm (accounting) keyword can, however, be depended on.

The information displayed is only a snapshot of a constantly changing system.