ps – report process status

ps command
ps command

ps displays information about running processes. It’s essential for monitoring and managing system processes.

Synopsis

ps [OPTIONS]

Common Options

OptionDescription
auxAll processes, user-oriented format
-efAll processes, full format
-u USERProcesses for specific user
-p PIDSpecific process by PID
--forestShow process tree
-o FORMATCustom output columns

Examples

Show all processes (BSD style)

$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1 169592 13092 ?        Ss   Jan15   0:03 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Jan15   0:00 [kthreadd]
greys    12345  0.5  1.2 456789 98765 pts/0    Ss   10:00   0:05 -bash

Show all processes (System V style)

$ ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Jan15 ?        00:00:03 /sbin/init
greys    12345 12340  0 10:00 pts/0    00:00:05 -bash

Show processes for current user

$ ps -u $USER

Show specific process

$ ps -p 1234
$ ps -p 1234 -o pid,ppid,cmd,%cpu,%mem

Process tree

$ ps --forest
$ ps auxf    # With forest

Custom output format

$ ps -eo pid,ppid,user,%cpu,%mem,cmd --sort=-%cpu | head

Find process by name

$ ps aux | grep nginx
$ pgrep -a nginx    # Alternative

Understanding ps aux Output

USER       PID %CPU %MEM    VSZ   RSS TTY  STAT START   TIME COMMAND
│          │    │    │       │     │   │    │    │       │    │
│          │    │    │       │     │   │    │    │       │    └─ Command
│          │    │    │       │     │   │    │    │       └─ CPU time
│          │    │    │       │     │   │    │    └─ Start time
│          │    │    │       │     │   │    └─ State (S=sleep, R=running)
│          │    │    │       │     │   └─ Terminal
│          │    │    │       │     └─ Resident memory (KB)
│          │    │    │       └─ Virtual memory (KB)
│          │    │    └─ Memory %
│          │    └─ CPU %
│          └─ Process ID
└─ Owner

Process States (STAT)

CodeMeaning
RRunning
SSleeping
DUninterruptible sleep
ZZombie
TStopped

Tips

  • Use pgrep: pgrep nginx is cleaner than ps aux | grep nginx
  • Watch processes: watch -n 1 'ps aux --sort=-%cpu | head'
  • For real-time: Use top or htop instead
  • Find parent: Use ps -p PID -o ppid= to get parent PID

See Also

  • top — Real-time process viewer
  • htop — Interactive process viewer
  • kill — Send signals to processes
  • pgrep — Find processes by name

Tutorials