SHARP Zaurus
ザウルスサポートステーション


PS

Section: Linux User's Manual (1)
Updated: March 11, 1999
Index Return to Main Contents
Licensed under version 2 of the GNU General Public License.
Modified by Michael K. Johnson from a gross plain-text hack by Albert Cahalan of Michael's original version.
 

NAME

ps - report process status  

SYNOPSIS

ps [options]

 

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.

 

COMMAND-LINE OPTIONS

This version of ps accepts several kinds of options.

Unix98 options may be grouped and must be preceeded by a dash.
BSD options may be grouped and must not be used with a dash.
GNU long options are preceeded by two dashes.

Options of different types may be freely mixed.

Set the I_WANT_A_BROKEN_PS environment variable to force BSD syntax even when options are preceeded by a dash. The PS_PERSONALITY environment variable (described below) provides more detailed control of ps behavior.

 

SIMPLE PROCESS SELECTION

SwitchDescription
-Aselect all processes
-Nnegate selection
-aselect all with a tty except session leaders
-dselect all, but omit session leaders
-eselect all processes
Tselect all processes on this terminal
a select all processes on a terminal, including those of other users
g really all, even group leaders (does nothing w/o SunOS settings)
rrestrict output to running processes
xselect processes without controlling ttys
--deselectnegate selection

 

PROCESS SELECTION BY LIST

SwitchDescription
-Cselect by command name
-Gselect by RGID (supports names)
-Uselect by RUID (supports names)
-gselect by session leader OR by group name
-pselect by PID
-sselect processes belonging to the sessions given
-tselect by tty
-uselect by effective user ID (supports names)
Uselect processes for specified users
pselect by process ID
tselect by tty
--Groupselect by real group name or ID
--Userselect by real user name or ID
--groupselect by effective group name or ID
--pidselect by process ID
--sidselect by session ID
--ttyselect by terminal
--userselect by effective user name or ID
-123implied --sid
123implied --pid

 

OUTPUT FORMAT CONTROL

SwitchDescription
-Ois preloaded "-o"
-cdifferent scheduler info for -l option
-fdoes full listing
-jjobs format
-llong format
-ouser-defined format
-ydo not show flags; show rss in place of addr
Ois preloaded "o" (overloaded)
Xold Linux i386 register format
jjob control format
ldisplay long format
ospecify user-defined format
sdisplay signal format
udisplay user-oriented format
vdisplay virtual memory format
--formatuser-defined format

 

OUTPUT MODIFIERS

SwitchDescription
-Hshow process hierarchy (forest)
-mshow threads
-nset namelist file
-wwide output
Cuse raw CPU time for %CPU instead of decaying average
Nspecify namelist file
Osorting order (overloaded)
S include some dead child process data (as a sum with the parent)
ctrue command name
eshow environment after the command
fASCII-art process hierarchy (forest)
h do not print header lines (repeat header lines in BSD personality)
mall threads
nnumeric output for WCHAN and USER
wwide output
--colsset screen width
--columnsset screen width
--cumulative include some dead child process data (as a sum with the parent)
--forestASCII art process tree
--htmlHTML escaped output
--headersrepeat header lines
--no-headersprint no header line at all
--linesset screen height
--nulunjustified output with NULs
--nullunjustified output with NULs
--rowsset screen height
--sortspecify sorting order
--widthset screen width
--zerounjustified output with NULs

 

INFORMATION

SwitchDescription
-Vprint version
Llist all format specifiers
Vshow version info
--helpprint help message
--infoprint debugging info
--versionprint version

 

OBSOLETE

SwitchDescription
Aincrease the argument space (DecUnix)
Muse alternate core (try -n or N instead)
Wget swap info from ... not /dev/drum (try -n or N instead)
kuse /vmcore as c-dumpfile (try -n or N instead)

 

NOTES

The "-g" option can select by session leader OR by group name. Selection by session leader is specified by many standards, but selection by group is the logical behavior that several other operating systems use. This ps will select by session leader when the list is completely numeric (as sessions are). Group ID numbers will work only when some group names are also specified.

The "m" option should not be used. Use "-m" or "-o" with a list. ("m" displays memory info, shows threads, or sorts by memory use)

The "h" option is problematic. Standard BSD ps uses the option to print a header on each page of output, but older Linux ps uses the option to totally disable the header. This version of ps follows the Linux usage of not printing the header unless 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 to enable printing headers each page and disable headers entirely, respectively.

Terminals (ttys, or screens of text output) can be specified in several forms: /dev/ttyS1, ttyS1, S1. Obsolete "ps t" (your own terminal) and "ps t?" (processes without a terminal) syntax is supported, but modern options ("T", "-t" with list, "x", "t" with list) should be used instead.

The BSD "O" option can act like "-O" (user-defined output format with some common fields predefined) or can be used to specify sort order. Heuristics are used to determine the behavior of this option. To ensure that the desired behavior is obtained, specify the other option (sorting or formatting) in some other way.

For sorting, BSD "O" option syntax is O[+|-]k1[,[+|-]k2[,...]] Order the process listing according to the multilevel sort specified by the sequence of short keys from SORT KEYS, k1, k2, ... The `+' is quite optional, merely re-iterating the default direction on a key. `-' reverses direction only on the key it precedes. The O option must be the last option in a single command argument, but specifications in successive arguments are catenated.

GNU sorting syntax is --sortX[+|-]key[,[+|-]key[,...]] Choose a multi-letter key from the SORT KEYS section. X may be any convenient separator character. To be GNU-ish use `='. The `+' is really optional since default direction is increasing numerical or lexicographic order. For example, ps jax --sort=uid,-ppid,+pid

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

This ps needs access to a namelist file for proper WCHAN display. The namelist file must match the current Linux kernel exactly for correct output.

To produce the WCHAN field, ps needs to read the System.map file created when the kernel is compiled. The search path is:

$PS_SYSTEM_MAP
/boot/System.map-`uname -r`
/boot/System.map
/lib/modules/`uname -r`/System.map
/usr/src/linux/System.map
/System.map
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. (Somebody fix libc or the kernel please.)

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

%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).

Processes marked <defunct> are dead processes (so-called "zombies") that remain because their parent has not destroyed them properly. These processes will be destroyed by init(8) if the parent process exits.

 

PROCESS FLAGS

ALIGNWARN001print alignment warning msgs
STARTING002being created
EXITING004getting shut down
PTRACED010set if ptrace (0) has been called
TRACESYS020tracing system calls
FORKNOEXEC040forked but didn't exec
SUPERPRIV100used super-user privileges
DUMPCORE200dumped core
SIGNALED400killed by a signal

 

PROCESS STATE CODES

Duninterruptible sleep (usually IO)
Rrunnable (on run queue)
Ssleeping
Ttraced or stopped
Za defunct ("zombie") process

For BSD formats and when the "stat" keyword is used, additional letters may be displayed:
Whas no resident pages
<high-priority process
Nlow-priority task
Lhas pages locked into memory (for real-time and custom IO)

 

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. Pipe ps output into the sort(1) command if you want to sort the cooked values.

KEYLONGDESCRIPTION
ccmdsimple name of executable
Ccmdlinefull command line
fflagsflags as in long format F field
gpgrpprocess group ID
Gtpgidcontrolling tty process group ID
jcutimecumulative user time
Jcstimecumulative system time
kutimeuser time
Kstimesystem time
mmin_fltnumber of minor page faults
Mmaj_fltnumber of major page faults
ncmin_fltcumulative minor page faults
Ncmaj_fltcumulative major page faults
osessionsession ID
ppidprocess ID
Pppidparent process ID
rrssresident set size
Rresidentresident pages
ssizememory size in kilobytes
Sshareamount of shared pages
tttythe minor device number of tty
Tstart_timetime process was started
Uuiduser ID number
uuseruser name
vvsizetotal VM size in bytes
yprioritykernel scheduling priority

 

AIX FORMAT DESCRIPTORS

This ps supports AIX format descriptors, which work somewhat like the formatting codes of printf(1) and printf(3). For example, the normal default output can be produced with this: ps -eo "%p %y %x %c"

CODENORMALHEADER
%Cpcpu%CPU
%GgroupGROUP
%PppidPPID
%UuserUSER
%aargsCOMMAND
%ccommCOMMAND
%grgroupRGROUP
%nniceNI
%ppidPID
%rpgidPGID
%tetimeELAPSED
%uruserRUSER
%xtimeTIME
%yttyTTY
%zvszVSZ

 

STANDARD FORMAT SPECIFIERS

These may be used to control both output format and sorting.
For example: ps -eo pid,user,args --sort user

CODEHEADER
%cpu%CPU
%mem%MEM
alarmALARM
argsCOMMAND
blockedBLOCKED
bsdstartSTART
bsdtimeTIME
cC
caughtCAUGHT
cmdCMD
commCOMMAND
commandCOMMAND
cputimeTIME
drsDRS
dsizDSIZ
egidEGID
egroupEGROUP
eipEIP
espESP
etimeELAPSED
euidEUID
euserEUSER
fF
fgidFGID
fgroupFGROUP
flagF
flagsF
fnameCOMMAND
fsgidFSGID
fsgroupFSGROUP
fsuidFSUID
fsuserFSUSER
fuidFUID
fuserFUSER
gidGID
groupGROUP
ignoredIGNORED
intpriPRI
limLIM
longtnameTTY
lstartSTARTED
m_drsDRS
m_trsTRS
maj_fltMAJFL
majfltMAJFLT
min_fltMINFL
minfltMINFLT
niNI
niceNI
nwchanWCHAN
opriPRI
pageinPAGEIN
pcpu%CPU
pendingPENDING
pgidPGID
pgrpPGRP
pidPID
pmem%MEM
ppidPPID
priPRI
rgidRGID
rgroupRGROUP
rssRSS
rssizeRSS
rszRSZ
ruidRUID
ruserRUSER
sS
sessSESS
sessionSESS
sgi_pP
sgi_rssRSS
sgidSGID
sgroupSGROUP
sidSID
sigPENDING
sig_blockBLOCKED
sig_catchCATCHED
sig_ignoreIGNORED
sig_pendSIGNAL
sigcatchCAUGHT
sigignoreIGNORED
sigmaskBLOCKED
stackpSTACKP
startSTARTED
start_stackSTACKP
start_timeSTART
statSTAT
stateS
stimeSTIME
suidSUID
suserSUSER
svgidSVGID
svgroupSVGROUP
svuidSVUID
svuserSVUSER
szSZ
timeTIME
timeoutTMOUT
tmoutTMOUT
tnameTTY
tpgidTPGID
trsTRS
trssTRSS
tsizTSIZ
ttTT
ttyTT
tty4TTY
tty8TTY
ucommCOMMAND
uidUID
uid_hackUID
unameUSER
userUSER
vsizeVSZ
vszVSZ
wchanWCHAN

 

ENVIRONMENT VARIABLES

The following environment variables could affect ps:
COLUMNSOverride default display width
LINESOverride default display height
PS_PERSONALITYSet to one of posix,old,linux,bsd,sun,digital
CMD_ENVSet to one of posix,old,linux,bsd,sun,digital
I_WANT_A_BROKEN_PSForce obsolete command line interpretation
LC_TIMEDate format
PS_FORMATDefault output format override
PS_SYSMAPDefault namelist (System.map) location
PS_SYSTEM_MAPDefault namelist (System.map) location
POSIXLY_CORRECTDon't find excuses to ignore bad "features"
UNIX95Don't find excuses to ignore bad "features"
_XPGCancel CMD_ENV=irix non-standard behavior

In general, it is a bad idea to set these variables. The two exceptions are CMD_ENV (or PS_PERSONALITY), to set the desired default personality, and POSIXLY_CORRECT (or UNIX95), which should be set for Unix98 standard compliance.

PS_PERSONALITYDescription
none"Do the right thing"
aixlike AIX ps
bsdlike FreeBSD ps
compaqlike Digital Unix ps
debianlike the old Debian ps
digitallike Digital Unix ps
gnulike the old Debian ps
hplike HP-UX ps
hpuxlike HP-UX ps
irixlike Irix ps
linuxdeviate from Unix98 for convenience only
oldlike the original Linux ps
posixstandard
scolike SCO ps
sgilike Irix ps
sunlike SunOS 4 ps
sunoslike SunOS 4 ps
sysvstandard
unixstandard
unix95standard
unix98standard

 

EXAMPLES

To see every process on the system using standard syntax:

ps -e
To see every process on the system using BSD syntax:
ps ax
To see every process except those running as root (real & effective ID)
ps -U root -u root -N
To see every process with a user-defined format:
ps -eo pid,tt,user,fname,tmout,f,wchan
Odd display with AIX field descriptors:
ps -o "%u : %U : %p : %a"
Print only the process IDs of syslogd:
ps -C syslogd -o pid=

 

SEE ALSO

top(1) pstree(1) proc(5)

 

STANDARDS

This ps can be set to conform to version 2 of the Single Unix Specification.

 

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 <shields@msrl.com> 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 Mosberger-Tang wrote the generic BFD support for psupdate.
Albert Cahalan <acahalan@cs.uml.edu> rewrote ps for full Unix98 and BSD support, along with some ugly hacks for obsolete and foreign syntax.

Michael K. Johnson <johnsonm@redhat.com> is the current maintainer.

Please send bug reports to <procps-bugs@redhat.com>


 

Index

NAME
SYNOPSIS
DESCRIPTION
COMMAND-LINE OPTIONS
SIMPLE PROCESS SELECTION
PROCESS SELECTION BY LIST
OUTPUT FORMAT CONTROL
OUTPUT MODIFIERS
INFORMATION
OBSOLETE
NOTES
PROCESS FLAGS
PROCESS STATE CODES
SORT KEYS
AIX FORMAT DESCRIPTORS
STANDARD FORMAT SPECIFIERS
ENVIRONMENT VARIABLES
EXAMPLES
SEE ALSO
STANDARDS
AUTHOR