ps - report a snapshot of the current processes
ps [aux] [-ef] [-eo FORMAT] [--sort KEY]
Options you will use
aux- BSD syntax: every process, with user and TTY-less ones included.
-ef- UNIX syntax: every process, full format (shows PPID).
-e- Select all processes.
-o FORMAT- Pick your own columns: pid,ppid,user,rss,vsz,stat,etime,comm,args. A trailing = drops the header.
-p PID- Only these PIDs.
--sort KEY- Sort by a column; prefix with - for descending (--sort=-rss).
-f, --forest- Show the process hierarchy.
--no-headers- Print no header line.
--ppid PID- Only the children of this parent PID.
-a- All processes with a terminal, except session leaders.
-C NAME- Only processes whose command name is NAME.
-L- Show threads, one line each (LWP column).
-u USER- Only processes of this (effective) user.
Examples
$ ps -eo pid,user,rss,comm --sort=-rss | headbiggest memory consumers
$ ps -p $$ -o ppid=what launched your shell
$ ps -p 1 -o comm=systemd
Gotchas
- STAT: R running/runnable, S interruptible sleep, D uninterruptible sleep (cannot be killed, usually blocked I/O), Z zombie (already dead, parent has not reaped it), T stopped. Modifiers: s session leader, l multi-threaded, + foreground, < high priority, N low priority.
Taught in
Try ps in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.