ps Cheatsheet - Linux Process Management Reference

Locating a process, finding what is eating memory, or obtaining a PID to pass to kill almost always starts with ps. The sheet is organised into basic viewing, filtering, custom output, process trees, threads and common scenarios, and its central concern is the difference between the BSD and System V dialects. ps aux reports user, PID, CPU%, memory%, VSZ, RSS, TTY, state and command, while ps -ef selects all processes with -e and prints a full-format line; both see everything, but the columns differ. Choosing one and staying with it matters more than learning both. To find memory consumers use --sort=-%mem, and the trap to avoid is confusing RSS with VSZ: RSS is resident memory in kilobytes, mixing them is the main source of wrong answers to "how much is this using". Process trees expose parent-child relationships, and a zombie in state Z cannot be killed, so the parent must be dealt with or the host restarted.

SysOps·35 commands·Last updated 2026-07-21
psProcesseslinuxProcess Management

Basic View 6

ps
Processes in the current terminal
ps aux
All processes (BSD style)
ps -ef
All processes (System V style)
ps -e
All processes
ps -f
Full-format output
ps -l
Long-format output

Filter 7

ps -p 1234
Process by PID
ps -p 1234,5678
Multiple PIDs
ps -u username
Processes of a user (effective)
ps -U username
Processes of a real user
ps -g groupname
Processes of a group
ps -C nginx
Processes by command name
ps --ppid 1234
Child processes of a parent PID

Custom Format 7

ps -eo pid,comm,user
Select output columns
ps -eo pid,ppid,comm,%cpu,%mem
PID, parent, command, CPU and memory
ps -eo pid,comm,etime
Process elapsed time
ps -eo pid,comm,stat
Process state
ps aux --sort=-%cpu
Sort by CPU usage, descending
ps aux --sort=%mem
Sort by memory usage, ascending
ps aux --sort=-rss
Sort by resident memory, descending

Process Tree 5

ps -ejH
Show process tree (System V style)
ps axjf
Show process tree (BSD style)
pstree
Show process tree (needs psmisc)
pstree -p
Process tree with PIDs
pstree -u
Process tree with users

Threads 4

ps -eLf
Show all threads
ps -p 1234 -L
Threads of a given process
ps -eT
Show thread IDs
ps -H -p 1234
Thread hierarchy of a process

Common Patterns 6

ps aux | grep nginx
Find nginx processes
ps aux --sort=-%cpu | head
Top CPU consumers
ps aux --sort=-%mem | head
Top memory consumers
ps -ef | grep defunct
Find zombie processes
ps -eo pid,comm,etime | grep -v defunct
Non-zombie processes with elapsed time
ps -u username -o pid,comm,%cpu,%mem
A user's process resource usage

Command Examples

Print the five busiest CPU processes

ps aux --sort=-%cpu | head -6

--sort 支持 -key 降序、key 升序。管道接 head 就能拿到 Top N,不必进交互式 top。

Output

USER  PID %CPU %MEM    VSZ   RSS TTY  STAT START   TIME COMMAND
root    1  0.0  0.1 168404 12164 ?    Ss   Aug29   0:03 systemd
tom   3120 48.2  8.1 1258300 318204 ?  Sl   10:12   2:14 node

Inspect the process tree to find the parent

pstree -p $(pgrep -f "node server.js")

pstree -p 显示 PID,能直观看出父进程是谁。排查「进程被谁启动的」「为什么杀了又起」这类问题时比 ps -ef 更直观。

Output

bash [1201]
├─ node [3120]
│  └─ node [3121]
└─ pm2 [1200]

Order by the exact column you care about

ps -eo pid,ppid,comm,%cpu,%mem --sort=-%cpu | head -10

-eo 自定义列,输出干净可控;加 ppid 能看出进程父子关系。ps aux 里那串长路径和启动参数对排序没有帮助。

Output

  PID  PPID COMMAND         %CPU %MEM
 3120  1200 node             48.2   8.1
 1452   840 chrome           18.2  12.4
 2031  1200 electron         12.7   6.8

Common Pitfalls

  • ps aux | grep xxx also matches the grep process itself; add grep -v grep or use pgrep.
  • ps shows only an instantaneous snapshot — use top -d or sar for sustained high usage.
  • kill sends SIGTERM for a graceful shutdown; -9 is SIGKILL and can lose unsaved data.
  • Zombie processes have already-dead parents, so killing the child does nothing — the parent or a reboot must reap them.
  • ps -ef and ps aux are different output formats with different columns; mixing them in scripts invites parse errors.

Tips

  • Both ps aux and ps -ef list all processes; aux is BSD style, -ef is System V style.
  • ps is a snapshot; top/htop show live data.
  • Zombie state is Z; you can't kill it — kill its parent or reboot.

Official References

Each command links to its official documentation below, so you can verify the latest usage and read deeper.

Maintained by LaoHand

Publicly updated on Jul 21, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us