Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
The ONE Campaign to make poverty history

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
Copyright Info
Terms of Use
Privacy Info
Masthead / Impressum
Your Account

Private Messages

News Archive
Submit News
User Articles
Web Links


The Web

Who's Online
There are currently, 113 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here



ps [options]

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.


This version of ps accepts several kinds of options.

Unix 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.

-A           select all processes
-N           negate selection
-a           select all with a tty except session leaders
-d           select all, but omit session leaders
-e           select all processes
T            select 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)
r            restrict output to running processes
x            select processes without controlling ttys
--deselect   negate selection

-C           select by command name
-G           select by RGID (supports names)
-U           select by RUID (supports names)
-g           select by session leader OR by group name
-p           select by PID
-s           select processes belonging to the sessions given
-t           select by tty
-u           select by effective user ID (supports names)
U            select processes for specified users
p            select by process ID
t            select by tty
--Group      select by real group name or ID
--User       select by real user name or ID
--group      select by effective group name or ID
-l           long format
-o           user-defined format
-y           do not show flags; show rss in place of addr
O            is preloaded "o" (overloaded)
X            old Linux i386 register format
j            job control format
l            display long format
o            specify user-defined format
s            display signal format
u            display user-oriented format
v            display virtual memory format
--format     user-defined format
--context    (SELinux only) Display security context format; implies --secsid
--secsid     (SELinux only) Display Security ID

-H           show process hierarchy (forest)
-m           show threads
-n           set namelist file
-w           wide output
C            use raw CPU time for %CPU instead of decaying average
N            specify namelist file
O            sorting order (overloaded)
S            include some dead child process data (as a sum with the parent)
c            true command name
e            show environment after the command
f            ASCII-art process hierarchy (forest)
h            no header (or, one header per screen in the BSD personality)
m            all threads
n            numeric output for WCHAN and USER
w            wide output
--cols       set screen width
--columns    set screen width
--cumulative include some dead child process data (as a sum with the parent)
--forest     ASCII art process tree
--headers    repeat header lines, one per page of output
--no-headers print no header line at all
--lines      set screen height
--rows       set screen height
--sort       specify sorting order
--width      set screen width

-V          print version
L           list all format specifiers
V           show version info
--help      print help message
--info      print debugging info
--version   print version

A           increases the argument space (DecUnix)
such as WCHAN ("ps -o pid,wchan=WIDE-WCHAN-COLUMN -o comm").
The behavior of "ps -o pid=X,comm=Y" varies with personality;
output may be one column named "X,comm=Y" or two columns
named "X" and "Y". Use multiple -o options when in doubt.

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 for 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

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


FORKNOEXEC   1    forked but didn't exec
SUPERPRIV    2    used super-user privileges
DUMPCORE     4    dumped core


D uninterruptible sleep (usually IO)
R runnable (on run queue)
S sleeping
T traced or stopped
W paging
X dead
Z a defunct ("zombie") process

For BSD formats and when the "stat" keyword is used, additional
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)


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.

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 kB
y   priority   kernel scheduling priority


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"

%C    pcpu      %CPU
%G    group     GROUP
%P    ppid      PPID
%U    user      USER
%a    args      COMMAND
%c    comm      COMMAND
%g    rgroup    RGROUP
%n    nice      NI
%p    pid       PID
%r    pgid      PGID
%t    etime     ELAPSED
%u    ruser     RUSER
%x    time      TIME
%y    tty       TTY
%z    vsz       VSZ


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

%cpu         %CPU
%mem         %MEM
alarm        ALARM
args         COMMAND
blocked      BLOCKED
bsdstart     START
bsdtime      TIME
euid         EUID
euser        EUSER
f            F
fgid         FGID
fgroup       FGROUP
flag         F
flags        F
fname        COMMAND
fsgid        FSGID
fsgroup      FSGROUP
fsuid        FSUID
fsuser       FSUSER
fuid         FUID
fuser        FUSER
gid          GID
group        GROUP
ignored      IGNORED
intpri       PRI
lim          LIM
longtname    TTY
lstart       STARTED
m_drs        DRS
m_trs        TRS
maj_flt      MAJFL
majflt       MAJFLT
min_flt      MINFL
minflt       MINFLT
ni           NI
nice         NI
nwchan       WCHAN
opri         PRI
pagein       PAGEIN
pcpu         %CPU
pending      PENDING
pgid         PGID
pgrp         PGRP
pid          PID
pmem         %MEM
ppid         PPID
pri          PRI
priority     PRI
rgid         RGID
rgroup       RGROUP
rss          RSS
rssize       RSS
rsz          RSZ
ruid         RUID
ruser        RUSER
s            S
secsid       SECSID
sess         SESS
session      SESS
start        STARTED
start_stack  STACKP
start_time   START
stat         STAT
state        S
stime        STIME
suid         SUID
suser        SUSER
svgid        SVGID
svgroup      SVGROUP
svuid        SVUID
svuser       SVUSER
sz           SZ
time         TIME
timeout      TMOUT
tmout        TMOUT
tname        TTY
tpgid        TPGID
trs          TRS
trss         TRSS
tsiz         TSIZ
tt           TT
tty          TT
tty4         TTY
tty8         TTY
ucmd         CMD
ucomm        COMMAND
uid          UID
uid_hack     UID
uname        USER
user         USER
vsize        VSZ
vsz          VSZ
wchan        WCHAN

The following environment variables could affect ps:
    COLUMNS             Override default display width.
    LINES               Override default display height.
    PS_PERSONALITY      Set to one of posix,old,linux,bsd,sun,digital...
    CMD_ENV             Set to one of posix,old,linux,bsd,sun,digital...
    I_WANT_A_BROKEN_PS  Force obsolete command line interpretation.
    LC_TIME             Date format.
    PS_COLORS           Not currently supported.
    PS_FORMAT           Default output format override.
    PS_SYSMAP           Default namelist (System.map) location.
    PS_SYSTEM_MAP       Default namelist (System.map) location.
    POSIXLY_CORRECT     Don't find excuses to ignore bad "features".
    UNIX95              Don't find excuses to ignore bad "features".
    digital  like Digital Unix ps
    gnu      like the old Debian ps
    hp       like HP-UX ps
    hpux     like HP-UX ps
    irix     like Irix ps
    linux    ***** RECOMMENDED *****
    old      like the original Linux ps (totally non-standard)
    posix    standard
    sco      like SCO ps
    sgi      like Irix ps
    sun      like SunOS 4 ps (totally non-standard)
    sunos    like SunOS 4 ps (totally non-standard)
    sysv     standard
    unix     standard
    unix95   standard
    unix98   standard

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=

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

This ps conforms to version 2 of the Single Unix Specification.

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

Show your Support for the Linux Tutorial

Purchase one of the products from our new online shop. For each product you purchase, the Linux Tutorial gets a portion of the proceeds to help keep us going.



Security Code
Security Code
Type Security Code

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!

Amazon Wish List

Did You Know?
The Linux Tutorial welcomes your suggestions and ideas.


Tell a Friend About Us

Bookmark and Share

Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.07 Seconds