Process status, information about processes running in memory. If you want a repetitive update of this status, use top.
Display Process info
List all the keyword options
This version of ps accepts 3 kinds of option:
-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. The PS_PERSONALITY
environment variable provides more detailed control of ps behavior.
The Options below are listed side-by-side (unless there are differences).
SIMPLE PROCESS SELECTION
-A a select all processes (including those of other users)
-a select all with a tty except session leaders
-d select all, but omit session leaders
-e select all processes
g really all, even group leaders (does nothing w/o SunOS settings) -N negate selection
r restrict output to running processes
T select all processes on this terminal
x select processes without controlling ttys
–deselect negate selection
PROCESS SELECTION BY LIST
-C select by command name
-G select by RGID (supports names)
-g select by session leader OR by group name
–Group select by real group name or ID
–group select by effective group name or ID
-p p –pid select by process ID (PID)
-s –sid select by session ID
-t –tty select by terminal (tty)
-u U select by effective user ID (supports names)
-U select by RUID (supports names)
–User select by real user name or ID
–user select by effective user name or ID
-123 implied –sid
123 implied –pid
OUTPUT FORMAT CONTROL
-c Different scheduler info for -l option
-f Full listing
-j j Jobs format
-l l Long format
-O O Add the information associated with the space or comma separated
list of keywords specified, after the process ID, in the default
-o o Display information associated with the space or comma separated
list of keywords specified.
–format user-defined format
s display signal format
u display user-oriented format
v display virtual memory format
X old Linux i386 register format
-y do not show flags; show rss in place of addr
C use raw CPU time for &qt;CPU instead of decaying average
c true command name
e show environment after the command
f ASCII-art process hierarchy (forest)
-H show process hierarchy (forest)
h do not print header lines (repeat header lines in BSD personality)
-m m show all threads
-n set namelist file
n numeric output for WCHAN and USER
N specify namelist file
O sorting order (overloaded)
S include some dead child process data (as a sum with the parent)
-w w wide output
–cols set screen width
–columns set screen width
–forest ASCII art process tree
–html HTML escaped output
–headers repeat header lines
–no-headers print no header line at all
–lines set screen height
–nul unjustified output with NULs
–null unjustified output with NULs
–rows set screen height
–sort specify sorting order
–width set screen width
–zero unjustified output with NULs
-V V print version
L list all format specifiers
–help print help message
–info print debugging info
–version print version
A increase the argument space (DecUnix)
M use alternate core (try -n or N instead)
W get swap info from … not /dev/drum (try -n or N instead)
k use /vmcore as c-dumpfile (try -n or N instead)
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 varies between BSD personality and Linux usage (not printing the header) Regardless of the current personality, you can use the long options –headers and –no-headers
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 &qt;+&qt;&qt; is quite optional, merely re-iterating the default direction on a key. &qt;-&qt;&qt; 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 &qt;=&qt;&qt;. The &qt;+&qt;&qt; 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:
/System.mapThe 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 Programs swapped out to disk will be shown without command line arguments, and unless the c option is given, in brackets.
&qt;CPU shows the cputime/realtime percentage. It will not add up to 100&qt; unless you are lucky. It is time used divided by the time the process has been running.
The SIZE and RSS fields don&qt;&qt;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 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.
ALIGNWARN 001 print alignment warning msgs
STARTING 002 being created
EXITING 004 getting shut down
PTRACED 010 set if ptrace (0) has been called
TRACESYS 020 tracing system calls
FORKNOEXEC 040 forked but didn&qt;&qt;t exec
SUPERPRIV 100 used super-user privileges
DUMPCORE 200 dumped core
SIGNALED 400 killed by a signal
PROCESS STATE CODES
D uninterruptible sleep (usually IO)
R runnable (on run queue)
T traced or stopped
Z a defunct ("zombie") process
For BSD formats and when the "stat" keyword is used, addi
tional letters may be displayed:
W has no resident pages
< high-priority process
N low-priority task
L has pages locked into memory (for real-time and custom IO)
ENVIRONMENT VARIABLES and PERSONALITY (posix,linux,bsd,sun)
To see every process on the system using standard syntax:
To see every process on the system using BSD syntax:
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 "&qt;u : &qt;U : &qt;p : &qt;a"
Print only the process IDs of syslogd:
ps -C syslogd -o pid=Since ps cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact.