PS(1)

NAME
ps - report process status

SYNOPSIS
There are two sets of command line options for ps, toggled by the Environment variable PS_PERSONALITY. BSD implementation of ps:

ps [-] [lujsvmaxgScewhrnu] [txx] [O[+|-]k1[[+|-]k2...]] [pids]

The second is modeled after the SVR4 resp. POSIX definition of the ps command. This is toggled by setting PS_PERSONALITY to POSIX:

ps [-[aAcdefjlNV]] [-[gG] grouplist] [-[uU] userlist] [-t tty] [-[ps] pidlist] [-o formatstring]

Both versions support the following long options: --sort [ + | - ] key[,[ + | - ] key[, ... ]]
--help
--version
--cumulative
--cols linewidth
--{user,User} userlist
--{group,Group} grouplist
--format formatstring
--forest
--{pid,sid} pidlist
--tty tty
--deselect
--width nr of lines

DESCRIPTION
ps gives a snapshot of the current processes. If you want a repetitive update of this status, use top. This man page documents the /proc-based version of ps, or tries to. ps will fit the output to the width of the current terminal. If it can't determin this (e.g. if output goes to a pipe), it will assume a line width of 80 chars. Using --cols you can force assumption of a line length.
  .PP

BSD STYLE COMMAND-LINE OPTIONS
The command-line options for this version of ps are derived from the BSD version of ps, not the System V version. The command-line arguments should not be preceeded by a `-' character, because in the future, a `-' will be used to indicate Unix98-standard command-line arguments, while no `-' will indicate the current ``extended BSD'' style of command line arguments.. For now, ps will give you a warning if you use a `-' for a short option, but it will still work. If you have shell scripts which use BSD-style arguments to ps, take heed of the warning and fix them, or else your scripts will fail to function correctly at some point in the future. There are also some ``long options'' in GNU style; see below for those.

l   long format
u   user format: gives user name and start time
j   jobs format: pgid sid
s   signal format
v   vm format
m   displays memory info (combine with p flag to get number of pages).
f   "forest" family tree format for command line
a   show processes of other users too
x   show processes without controlling terminal
g   ignored for compatibility reasons.
S   add child cpu time and page faults
c   command name from task_struct
e   show environment after command line and ` + '
w   wide output: don't truncate command lines to fit on one line. To be exact, every w that is specified will add another possible line to the output. If the space isn't needed it isn't used. You may up to 100 w's.
h   no header
r   running procs only
n   numeric output for USER and WCHAN.

txx only procs with controlling tty xx; for xx you may use either the name of a device file under "/dev" or that name with either tty or cu sliced off. This is the reverse heuristic that ps uses to print out the abbreviated tty name in the TT field, e.g. ps -t1.

O[+|-]k1[,[+|-]k2[,...]]
    Order the process listing according to the multi-level sort specified by the sequence of short keys from SORT KEYS, k1, k2, ... Default order specifications exist for each of the various formats of ps. These are over-ridden by a user specified ordering. The `+' is quite optional, merely re-iterating the default direction on a key. `-' reverses direction only on the key it precedes. As with t and pids, the O option must be the last option in a single command argument, but specifications in successive arguments are catenated.

pids
    List only the specified processes; they are comma-delimited. The list must be given immediately after the last option in a single command-line argument, with no intervening space, e.g. ps -j1,4,5. Lists specified in subsequent arguments are catenated, e.g. ps -l 1,2 3,4 5 6 will list all of the processes 1-6 in long format. If pids are given, they are listed no matter what. If a tty is given matching processes are listed no matter what. These two features override the 'a' and 'x' flags.

POSIX STYLE COMMAND-LINE OPTIONS
Note that you have to prepend options with a '-', conversely to the BSD style. Options without argument may, however, be grouped together.
-a  show information on all processes but process group leaders and processes not associated with a terminal (usually these are none or next to none, so this is useless in most cases).
-A  show information on all processes.
-c  compatibilty option (makes no sense on Linux machines).
-d  show information on all processes but process group leaders.
-e  show information on every process.
-f  use full format (uid,pid,ppid,start_time,tty,time,args)
-g  grouplist show information on processes whose group is in grouplist. Both group ids and group names may be specified in grouplist.
-G  grouplist same as -g but match list with the real group of the process.
-j  add job information (pgid,sid) to format
-l  use long format (flags,state,uid,pid,ppid,pri,nice,wchan,tty,time,comm)
-N  show information on all processes i but those corresponding to the command-line options specifying users, groups or process ids.
-o  formatstring user the format specified by formatstring. See below for more information.
-p  pidlist show information on processes whose id is specified in pidlist.
-s  sidlist show information on session leaders whose session id is specified in sidlist.
-t  tty show information on processes whose controlling terminal is tty.
-u  userlist show information on processes whose owner is in userlist. Both user ids and user names may be specified in userlist.
-U  userlist same as -u but match list with the real owner of the process. -V show version number. -w wide output: don't truncate command lines to fit on one line. To be exact, every w that is specified will add another possible line to the output. If the space isn't needed it isn't used. You may up to 100 w's. You may use more than one -g, -o, -p, -sand -u options. It isn't possible to use one of the options selecting real ids together with one using effective (i.e. usual) ids. If both are mixed, real ones are used for all selections.

LONG COMMAND-LINE OPTIONS
These options are preceeded by a double-hyphen.
--color
    try to use color markup of processes (see COLOR SUPPORT below).
--cumulative
    show cumulative times and page faults (as the BSD S command-line option).
--cols
    linewidth forces ps to assume lines are linewidth long.
--width
    nr of lines tells ps to use up to nr additional lines to display a single process.
--deselect
    as the POSIX -N option.
--forest
    as the BSD f option.
--format
    as the POSIX -o option.
--group,--Group
    as the POSIX -g resp. -G options.
--help
    Get a help message that summarizes the usage and gives a list of supported sort keys. This list may be more up to date than this man page.
--nocolor
    do not use color markup.
--pid,--sid
    as the POSIX -p resp. -s options.
--sort[+|-]key[,[+|-]key[,...]]
    Choose a multi-letter key from the SORT KEYS section. The `+' is really optional since default direction is increasing numerical or lexicographic order. E.g.: ps -jax --sort uid,-ppid,+pid
--tty
    as the POSIX -t option.
--user,--User
    as the POSIX -u resp. -U options.
--version
    Display version and source of this program.

SORT KEYS
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. If someone wants to volunteer to write special comparison functions for the cooked values, ... ;-) SHORT LONG DESCRIPTION
c       cmd             simple name of executable
C       cmdline         full command line
f       flags           flags as in long format F field
g       pgrp            process group ID
G       tpgid           controlling tty process group ID
j       cutime          cumulative user time
J       cstime          cumulative system time
k       utime           user time
K       stime           system time
m       min_flt         number of minor page faults
M       maj_flt         number of major page faults
n       cmin_flt        cumulative minor page faults
N       cmaj_flt        cumulative major page faults
o       session         session ID
p       pid             process ID
P       ppid            parent process ID
r       rss             resident set size
R       resident        resident pages
s       size            memory size in kilobytes
S       share           amount of shared pages
t       tty             the minor device number of tty
T       start_time      time process was started
U       uid             user ID number
u       user            user name
v       vsize           total VM size in bytes
y       priority        kernel scheduling priority

SEE ALSO
top(1), psupdate(8), libproc_output(3), readproc(3), openproc(3), /usr/include/proc/readproc.h, /usr/src/linux/fs/proc/array.c.

NOTES
The member used_math of task_struct is not shown, since crt0.s checks to see if math is present. This causes the math flag to be set for all processes, and so it is worthless.

Programs swapped out to disk will be shown without command line arguments, and unless the c option is given, in parentheses.

%CPU shows the cputime/realtime percentage. It will not add up to 100% unless you are lucky. It is time used divided by the time the process has been running.

The SIZE and RSS fields don't count the page tables and the task_struct of a proc; this is at least 12k of memory that is always resident. SIZE is the virtual size of the proc (code+data+stack).

To perform the device number to name mapping ps maintains a file called "/etc/psdevtab" (updated whenever "/dev" becomes newer and permissions allow update). If permissions do not allow update, every invokation of ps requires a stat(2) of every file in the "/dev" directory. If "/dev" entries change often on your system, you should run ps as root often. I may add a fallback file under $HOME under force of popular demand.

BUGS
There are probably a lot of bugs still in the ps and libproc code. One of the more often occurring problems is that there seem to be new serial devices every other week, so often ps does not recognize a device as a TTY device. To enable ps to recognize a new serial device simply add the major device number to the list in devname.c.

AUTHOR
ps was originally written by Branko Lankester <lankeste@fwi.uva.nl>. Michael K. Johnson <johnsonm@redhat.com> re-wrote it significantly to use the proc filesystem, changing a few things in the process. Michael Shields <mjshield@nyx.cs.du.edu> added the pid-list feature. Charles Blake <cblake@bbn.com> added multi-level sorting, the dirent-style library, the device name-to-number mmaped database, the approximate binary search directly on System.map, and many code and documentation cleanups. David Mossberger-Tang wrote the generic BFD support for psupdate. Michael K. Johnson <johnsonm@redhat.com> is the current maintainer. Helmut Geyer(Helmut.Geyer@iwr.uni-heidelberg.de) added support for POSIX style options, color support, arbitrary formats, a lot of documentation and libproc changes. Please send bug reports to <procps-bugs@redhat.com>