ps - report process status
Gives a snapshot of the current processes.

Options vary significantly depending on the O/S

Mac version

See top for dynamic display

-A all
-a all with a tty except session leaders
-d all,omit session leaders
-e all processes
T all on this terminal
a all processes on a terminal, including those of other users
g really all, even group leaders (does nothing w/o SunOS settings)
r only running processes
x select processes without controlling ttys
-N,
--deselect
negate selection

Process Selection By List

-u,--user effective user name or ID -g,--group effective group name/ ID
U,-U,--User real user name/ID -G,--Group real group name/ID
123 implied --pid
p,-p,--pid process ID
-123 implied --sid
--sid session ID
-s select processes belonging to the sessions given
t,-t,--tty terminal
-C command name

OUTPUT FORMAT CONTROL

       -f         full listing
UID        PID  PPID  C STIME TTY          TIME CMD
realger1 27441  5504  0 22:29 pts/2    00:00:00 -bash
realger1  6112 27441  0 22:29 pts/2    00:00:00 ps -f

    ps   O,O        is preloaded "o" (overloaded)

    ps   j,-j       job control
  PID  PGID   SID TTY          TIME CMD
27441 27441 27441 pts/2    00:00:00 bash
 1051  1051 27441 pts/2    00:00:00 ps
 
     ps  l,-l       long 
F S   UID   PID  PPID  C PRI  NI ADDR    SZ WCHAN  TTY          TIME CMD
0 S 32357 27441  5504  0  75   0    -  1332 -      pts/2    00:00:00 bash
0 R 32357 14766 27441  0  74   0    -   825 -      pts/2    00:00:00 ps

    ps   -yl         do not show flags; show resident set size in place of addr
S   UID   PID  PPID  C PRI  NI  RSS    SZ WCHAN  TTY          TIME CMD
S 32357 27441  5504  0  75   0 2564  1333 -      pts/2    00:00:00 bash
R 32357  7123 27441  0  74   0 1900   816 -      pts/2    00:00:00 ps

      ps -c         different scheduler info for -l option
  PID   CLS PRI TTY          TIME CMD
27441     -  24 pts/2    00:00:00 bash
  305     -  25 pts/2    00:00:00 ps

     ps  s          signal 
 UID   PID   PENDING   BLOCKED   IGNORED    CAUGHT STAT TTY        TIME COMMAND
32357 27441  00000000  00010000 <00384004  4b813efb S    pts/2      0:00 -bash
32357 23445  00000000  00000000 <00000000  73fbfaf9 R    pts/2      0:00 ps s

     ps  u          user-oriented
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
realger1 27441  0.0  0.1  5332 2564 pts/2    S    22:29   0:00 -bash
realger1  4478  0.0  0.0  2600 1204 pts/2    R    22:33   0:00 ps u
 
     ps  v          virtual memory 
  PID TTY      STAT   TIME  MAJFL   TRS   DRS  RSS %MEM COMMAND
27441 pts/2    S      0:00    296     0  7176 2564  0.1 -bash
 8774 pts/2    R      0:00    160     0  3904 1208  0.0 ps v

       o,-o,--format user-defined 
       X          old Linux i386 register format

OUTPUT MODIFIERS

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

INFORMATION

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

Notes

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

Terminals (ttys, or screens of text output) can be specified as:

sorting: 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 O must be the last option in a single command argument, but specifications in successive arguments are catenated.

--sortX[+|-]key[,[+|-]key[,…]]
example:

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
Programs swapped out will be shown without command line arguments, and unless the c option is given, in brackets.

%CPU shows the cputime/realtime percentage.

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 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 FORKNOEXEC 1 forked but didn't exec SUPERPRIV 2 used super-user privileges DUMPCORE 4 dumped core

PROCESS STATE CODES D uninterruptible sleep (usually IO) R runnable (on run queue) S sleeping T traced or stopped 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)

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.

       KEY   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

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"
      CODE   NORMAL   HEADER           CODE   NORMAL   HEADER
       %C     pcpu     %CPU
       %U     user     USER            %u     ruser    RUSER
       %G     group    GROUP           %g     rgroup   RGROUP
       %a     args     COMMAND        %c     comm     COMMAND
       %p     pid      PID            %P     ppid     PPID
       %r     pgid     PGID
       %n     nice     NI
       %t     etime    ELAPSED        %x     time     TIME
       %y     tty      TTY
       %z     vsz      VSZ
       
   

STANDARD FORMAT SPECIFIERS

used to control both output format and sorting. For example:
       %cpu          %CPU              %mem          %MEM
       alarm         ALARM
       args          COMMAND
       blocked       BLOCKED
       bsdstart      START
       bsdtime       TIME
       c             C
       caught        CAUGHT
       cp            CP
       cpu           CPU
       cmd           CMD
       comm          COMMAND         command       COMMAND
       drs           DRS
       dsiz          DSIZ
       euid          EUID            fsuid         FSUID
       ruid          RUID
       fuser         FUSER           fsuser        FSUSER    euser         EUSER           
       ruser         RUSER
       fgid          FGID            fsgid         FSGID     egid          EGID
       fgroup        FGROUP          fsgroup       FSGROUP   egroup        EGROUP          
       eip           EIP
       esp           ESP
       cputime       TIME            etime         ELAPSED
       f             F
       flag          F
       flags         F
       fname         COMMAND
       fuid          FUID
       suid          SUID uid           UID      svuid         SVUID
       uid_hack      UID
       uname         USER user          USER suser         SUSER
       gid           GID pgid          PGID pgrp          PGRP
       group         GROUP
       svgid         SVGID svgroup       SVGROUP
       rgid          RGID
       rgroup        RGROUP

       pid           PID                ppid          PPID
       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
       pmem          %MEM
       policy        POL
       pri           PRI
       rss           RSS             rssize        RSS
       rsz           RSZ
       rtprio        RTPRIO
       s             S
       sess          SESS            session       SESS
       sgi_p         P
       sgi_rss       RSS
       sgid          SGID
       sgroup        SGROUP
       sid           SID
       sig           PENDING
       sig_block     BLOCKED         sig_catch     CATCHED
       sigmask       BLOCKED
       sig_ignore    IGNORED         sig_pend      SIGNAL
       sigcatch      CAUGHT          sigignore     IGNORED
       start         STARTED
       start_stack   STACKP          stackp        STACKP
       start_time    START
       stat          STAT
       state         S
       stime         STIME
       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
       ucomm         COMMAND
       vsize         VSZ
       vsz           VSZ
       wchan         WCHAN

ENVIRONMENT VARIABLES

COLUMNS , LINES
LC_TIME Date format
CMD_ENV
PS_PERSONALITY
posix |old |linux |bsd |sun |digital
PS_FORMAT output format override
PS_SYSMAP
PS_SYSTEM_MAP
namelist (System.map) location
I_WANT_A_BROKEN_PS Force obsolete command line interpretation
_XPG Cancel CMD_ENV=irix non-standard behavior
POSIXLY_CORRECT
UNIX95
In general, it is a bad idea to set these variables.
except

PS_PERSONALITY Description

       none             
       aix              AIX                     
       bsd              FreeBSD 
       compaq,digital   Digital Unix            
       gnu,debian       the old Debian 
       hp,hpux          HP-UX          
       irix,SGI         Irix 
       linux            deviate from Unix98 for convenience only
       old              the original Linux 
       sco              SCO                     
       sun,sunos        SunOS 4                 
       posix            standard
       sysv, unix, unix95, unix98

EXAMPLES

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

BSD/Darwin/Mac OSX Sort processes by CPU time used

UID   PID  PPID C   STIME TTY       TIME
  /bin/ps -eafA|sort -k 1.40  |tail -20
503   149   117 0   0:16.63 ??   0:38.62 /Library/Application Support/WesternDigital/WDDriveManager/WDDriveManagerStatusMenu.app/Contents/MacOS/WDDriveManagerStatusMenu -psn_0_40970
503   123   117 0   0:09.52 ??   0:47.95 /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock
0    14     1   0   0:29.47 ??   0:50.01 /usr/libexec/configd
503   124   117 0   0:24.96 ??   1:02.52 /System/Library/CoreServices/SystemUIServer.app/Contents/MacOS/SystemUIServer
503 44312     1 0   0:09.77 ??   1:45.80 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker MDSImporterWorker com.apple.Spotlight.ImporterWorker.503
503   152   117 0   1:25.23 ??   2:07.05 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/Resources/SpeechSynthesisServer.app/Contents/MacOS/SpeechSynthesisServer -psn_0_53261
503  3239  3230 0   1:44.68 ttys002 2:19.05 -bash
503    55     1 0   1:22.39 ??   2:24.12 /System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow console
503   125   117 0   0:55.42 ??   3:07.18 /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
503 58430   117 0   1:01.80 ??   3:10.76 /Applications/iTunes.app/Contents/MacOS/iTunes -psn_0_2912967
0     1     0   0   6:26.68 ??   6:29.09 /sbin/launchd
0    58     1   0   2:44.18 ??   8:59.31 /usr/libexec/hidd
503  1854   117 0   1:00.90 ??  10:31.84 /Applications/Utilities/Activity Monitor.app/Contents/MacOS/Activity Monitor -psn_0_815303
503 53026   117 0   6:17.05 ??  20:45.93 /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin -psn_0_1421659
0    54     1   0   6:57.93 ??  24:43.86 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Support/mds
 88    90     1 0  10:31.71 ??  30:28.87 /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/WindowServer -daemon
503   203   117 0   2:39.92 ??  40:08.44 /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_106522
0  1856     1   0  32:41.63 ??  40:46.65 /Applications/Utilities/Activity Monitor.app/Contents/MacOS/activitymonitord
503 86026   117 0  11:06.52 ??  62:57.47 /Applications/Firefox.app/Contents/MacOS/firefox-bin -psn_0_2437715
202   114     1 0 188:55.23 ?? 200:44.06 /usr/sbin/coreaudiod

  

SEE ALSO

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