ps From Zero: What Every Process Is Doing, at a Glance
Which process is eating memory, who started whom, which one died but was never collected? ps answers all of it with one snapshot. This guide runs every command for real on procps-ng ps 4.0.4: default selection, Unix vs BSD vs GNU options, -o custom columns, --sort, --forest trees, the full STAT alphabet, a live zombie demo, and headerless output for scripts — plus the four classic traps.

There are hundreds of processes running on a system. Which one is eating memory, which one started which, which one has died but has not been collected yet — to answer any of these, the first command to learn is ps. Its manual says it in one sentence: "ps reports a snapshot of the current processes." The word snapshot is the key to understanding ps: it takes one photograph and does not do live video. If you want to watch processes change over time, use top; if you want to know what is there at one moment, one ps command is enough. Every command in this guide was run for real on procps-ng 4.0.4 ps, with output pasted verbatim. PIDs differ on every run, so this article quotes only the parts that do not change — headers, state letters, command names — and you should take the numbers from your own run.
Start with the simplest case. Run ps with no arguments, and it shows only the processes with the same effective user ID as you and associated with the same terminal, in four columns: PID (process ID), TTY (terminal), TIME (accumulated CPU time), and CMD (executable name). Output is unsorted by default. In a container or an environment without a terminal, bare ps may show only one or two lines — that does not mean the command is broken; its default selection set is just that small. The manual states it plainly: by default, ps selects processes with the same effective user ID as the invoker and associated with the same terminal. To see the whole system, you first widen the selection set, which is the next section's job.
The options of ps come in three styles, and this is where most people get confused. Unix-style options take one dash and can be grouped, like -ef. BSD-style options take no dash and can also be grouped, like aux. GNU long options take two dashes, like --forest and --sort. The three styles can be mixed freely, but mixing can cause conflicts. The manual adds a detail worth remembering: BSD-style options change the default behavior — they add the process state (STAT) column to the default display, print command arguments instead of just the executable name, and widen the selection to processes on other terminals owned by you. In other words, ps aux and ps -ef do not merely show different columns; they select different sets of processes. Keep that in mind, and much of the confusion about "why is the output different" goes away.
First hands-on test: look at one sleeping process. The demo for this guide starts a sleep 600, which sleeps in the background for 600 seconds, and then looks at it with three columns (PIDs differ on every run; this is the output of the run recorded for this article):
PID PPID STAT COMMAND 2913 2909 S sleep
The header is PID, PPID, STAT, COMMAND, and below it one line: the sleep process's own PID, its parent's PID, the state letter S, and the command name sleep. The PPID column is one of the most useful columns in ps: every process has a parent, and when the parent dies, the child is adopted by process 1 (systemd). Climb up the PPID chain and you can draw the whole process tree — the --forest section below does exactly that. The letter S means interruptible sleep: the process is waiting for something, asleep, using no CPU. A sleep command spends most of its life as S: it does nothing, just waits for its time to come.
Second test: select by command name. The command ps -C sleep -o pid,ppid,comm means: select only processes whose command name is sleep, and show only the PID, PPID, and COMMAND columns. The output of the recorded run:
PID PPID COMMAND 2913 2909 sleep
There is no other sleep process besides the demo's — on this machine, nobody normally runs sleep. The -C option selects by command name, not by command line: sleep 600 with an argument and plain sleep without one share the command name sleep, and both are selected. To select by PID, use -p; by parent process, use --ppid; by user, use -u or -U (one is the effective user, the other the real user). Selection options add up: a process is shown if it meets any of the given criteria — in the manual's words, process selection options are additive, not an intersection.
Third test: resource columns. The output of ps -o pid,ppid,%cpu,%mem,stat,comm -p 2913:
PID PPID %CPU %MEM STAT COMMAND 2913 2909 0.0 0.0 S sleep
The sleep process shows %CPU 0.0, %MEM 0.0, and STAT S. The %CPU column carries a classic misunderstanding that should be cleared up first: it is the average since the process started, not the usage "right now." A just-started process shows 0.0, and a long-running process has its %CPU diluted by a long history. To see who is eating CPU at this moment, use top, or take two ps snapshots a few seconds apart and compute the difference. %MEM is the share of physical memory the process uses, as a percentage of total memory. The column names after -o can be combined freely, in whatever order you write them; adding an equals sign and a name after a column renames its header, and writing -o pid= removes the header entirely — the trick every shell script relies on.
Fourth test: the process tree. Start a bash, have it start two sleeps, and look with ps --forest -o pid,ppid,comm -p 2917 --ppid 2917. The recorded output:
PID PPID COMMAND 2917 2909 bash 2919 2917 \_ sleep 2920 2917 \_ sleep
Two sleep processes hang under bash, marked with \_ tree branches. The --forest option draws the parent-child relationships; -p selects bash itself, --ppid selects its children, and together the tree is complete. The manual's standard spellings are ps -ejH and ps axjf, which do the same thing — draw "who gave birth to whom" as a tree. When debugging, a tree beats a flat list: a runaway script or a service that keeps restarting usually gives itself away two levels up the tree.
Fifth test: headerless output for scripts. The command ps -o pid= -p 2913 prints a single number: 2913. The command ps -o stat= -p 2913 prints a single letter: S. Leave the part after the equals sign empty and the header disappears, so the output can be fed straight to kill, stored in a variable, or tested in an if statement. Every "start it if it is not running" monitoring script uses this shape. A common combination is ps -C nginx -o pid= to get the PID — empty output means the service is not running. Note that -q (--quick-pid) is a faster PID lookup mode, but it does not accept extra sorting or forest options; -p is enough for everyday use.
Sixth test: the zombie process. A zombie is the most unsettling state in ps: the process has already exited, but its parent has not called wait to collect its exit status, so its entry in the process table remains, holding a PID, with state Z. The demo for this guide shows it with Python: the parent forks a child, the child exits immediately, and the parent sleeps for 0.3 seconds without collecting it. During that window, ps sees:
PID PPID STAT COMMAND 2925 2924 Z python3
Z is the zombie. A zombie uses no memory and no CPU; all it holds is one process-table entry. The real problem is the parent: if the parent never collects its children, zombies accumulate until the process table fills up and no new process can be created. The fix is not on the zombie, it is on the parent: fix the parent's wait logic, or kill the parent and let process 1 adopt and collect the zombie. When you see Z, do not panic — look at the PPID column first. That is the process that needs fixing.
The STAT column deserves a complete alphabet, because it is the most information-dense column ps has. The first letter is the main state: R means running or runnable, waiting for a CPU; S means interruptible sleep, waiting for an event — the normal state of most processes for most of their lives; D means uninterruptible sleep, usually waiting on disk I/O, and a process in D cannot even be killed; T means stopped, by SIGSTOP or while being debugged; Z means zombie; X means dead, which you will almost never see. After the first letter there may be extra modifier letters: < is high priority (nice value below zero), N is low priority (nice value above zero), s is a session leader, l is multithreaded, and + means the process is in the foreground process group, the one interacting with the terminal. A common line like Sl means "a sleeping, multithreaded process that is a session leader"; R+ means "a running foreground process." When reading ps output, read STAT first and the other columns second — the state tells you what the process is doing, and the other columns tell you who it is.
Seventh test: sort by memory to find the biggest users. The command ps -eo pid,ppid,%mem,comm --sort=-%mem | head -4 produces output whose rows change on every run, so only the column structure is quoted here:
PID PPID %MEM COMMAND
706 0 3.7 hatch
782 0 0.1 hatch-execd
1 0 0.0 systemd
After --sort, a column name sorts ascending, and a minus sign in front sorts descending; several column names can be given, separated by commas, as in --sort=-%mem,-pid. The -e option selects every process on the system, and -o takes just four columns. The head -4 here only trims the output to four lines for readability — to find the real top ten by memory, change 4 to 11 (one extra line for the header). The same pattern finds CPU hogs with --sort=-%cpu. Note that ps aux is an equivalent habit for many people, but its columns are fixed and cannot be changed; -eo with --sort is the proper way to cut the report to your own shape.
Finally, four classic traps, each worth remembering after the first time you step in it. First, bare ps shows very little, which does not mean the system is empty — by default it selects only your own processes on the same terminal, leaving out daemons, other users' processes, and processes on other terminals; to see the whole system, use ps -e or ps aux. Second, ps aux | grep sleep always shows one extra line, the grep process itself, because the word sleep appears in grep's own command line; either select by name directly with ps -C sleep, or write grep [s]leep so the full word sleep never appears in grep's command line. Third, %CPU is a lifetime average, not an instantaneous value — a process can be eating a whole CPU right now and still show 0.1 percent because it just started; to judge "who is eating CPU now," use top, or take two ps snapshots and look at the difference in the TIME column. Fourth, ps is a snapshot: it answers "what is there now," not "what happened just now" — a process that crashes instantly, short-lived processes, and the reason a start failed are all invisible to ps; that is journalctl and log files' job (journalctl has its own guide; ss covers network connections, df covers disks, and free covers memory — this guide covers ps only).
The two most-used full listings, ps -ef and ps aux, have completely different columns, and they are worth comparing column by column. The ps -ef columns are: UID (owner), PID, PPID, C (a rough CPU usage value), STIME (start time), TTY (terminal), TIME (accumulated CPU time), and CMD (full command line). The ps aux columns are: USER, PID, %CPU, %MEM, VSZ (virtual memory size), RSS (resident memory size), TTY, STAT, START, TIME, and COMMAND. Their jobs are distinct: -ef is Unix style, and its strength is "who started whom, when it started, and what the full command line is"; aux is BSD style, and its strength is "how many resources it uses and what state it is in." Use -ef to check whether a service is the one you started, reading the arguments in its full command line; use aux to check who is eating memory, reading %MEM and RSS. The VSZ and RSS distinction matters here: VSZ is the total virtual memory the process has asked for, including shared libraries and mapped files that are "nominally held but barely used," so the number is usually large; RSS is what actually sits in physical memory, and it is the number to read when judging how much memory a process really eats. Judging by VSZ alone mislabels many processes as memory hogs.
There are dozens of column names for -o, but only about fifteen see daily use, so here they are as a reference table: pid for the process ID, ppid for the parent process ID, pgid for the process group ID, sid for the session ID, tty for the terminal, stat for the state, %cpu for accumulated CPU share, %mem for memory share, vsz for virtual memory, rss for resident memory, etime for the elapsed time since the process started (in [[DD-]hh:]mm:ss format), time for accumulated CPU time, comm for the executable name, args or cmd for the full command line, nice for the priority adjustment, pri for the priority, wchan for what the process is waiting on inside the kernel (needs privileges), nlwp for the thread count, and lwp for the thread ID. TIME and ETIME are the pair people mix up most: TIME is the CPU time the process has consumed in total — a process that has slept for three days may have a TIME of only a few seconds — while ETIME is the real time elapsed since the process started, so a sleep 600 that has run for a minute shows ETIME 01:00. Use ETIME for "how long has it been running" and TIME for "how much work has it done." A column name can take a width after a colon to truncate it, as in the manual's example wchan:14, and an equals sign renames it, as in -o pid=PID. Combine these freely and ps becomes a report you cut to your own shape.
Threads are another capability of ps worth covering on their own. On Linux, threads and processes use the same mechanism, and a multithreaded process shows as a single line in ps's default output. To see its threads, add -L: ps -eLf adds NLWP (number of threads) and LWP (thread ID) columns, and the threads of one process appear as separate lines, with LWP as the thread's number in the kernel. The command ps -T shows only the current process's threads, and ps -L -p <PID> shows a specific process's threads. The lowercase l modifier in the STAT column means "this process is multithreaded," and seeing it is the cue to expand with -L. When an online service hangs, first use -L to see which thread is stuck in D state, then follow the wchan column to see what it is waiting on — that chain is the deepest diagnosis ps can give, and below it lie strace and perf.
The last piece of the puzzle is this: ps produces no data of its own; it only arranges the /proc directory into a table. Every number in /proc is a directory holding live information about the matching process: /proc/2913/status holds state, memory, and the parent process; /proc/2913/cmdline holds the full command line; /proc/2913/stat holds CPU time and start time. What ps does is read those files, arrange them into the columns you asked for, filter them by the rules you gave, and print them. Knowing this has two benefits. First, whatever ps cannot see, /proc probably does not have either — ps's capability boundary is the boundary of what the kernel exposes. Second, when ps hangs or its output looks wrong, you can read /proc directly to cross-check: if ps shows a process in D state, /proc/<PID>/status shows the same thing on its State line, with the wchan line beside it. In a script that needs just one or two numbers, reading /proc directly is more robust than parsing ps output; but for a complete, readable table, ps is still the handiest tool.
Here is a real debugging flow that ties the earlier sections together. Suppose a service fails to start, and the log only says "failed to start." Step one: ps -C <service> to see whether it is there at all — if it is not, the process never started or started and exited immediately, so the problem is in the startup phase, not the running phase. Step two: ps -ef | grep <service> to read the full command line and check whether the startup arguments and the config file path are right — many "won't start" cases are one wrong argument in the command line. Step three: ps --forest to see whether it left any child processes behind — some services work as "a parent starts a child, and the child does the work," and a parent present with no child means the child started and exited at once. Step four: read the STAT column — D means an I/O problem, T means it was stopped by someone or is being debugged, Z means the parent never collected it. Step five: read TIME and ETIME — a very short ETIME with TIME at zero means the process is restarting in a loop, and at that point the place to look is journalctl's logs, not ps. In this flow, ps's job is always "see the scene clearly first." It does not draw conclusions, but without it, conclusions usually land in the wrong place.
Two easily missed points to close. One is environment variables: PS_FORMAT can preset your usual -o column combination, and PS_PERSONALITY can change ps's default "personality" (for example, making it behave BSD-style by default). Put them in your shell configuration and they save keystrokes — but be careful putting them in shared scripts, because another machine may not have those variables, and the script's behavior will change with them. The other is permissions: ps can list every user's processes by default, but some details of other users' processes (sensitive arguments in the full command line, wchan) may be hidden or empty for lack of privilege. That is normal, not a broken command. Your own processes show everything; for the full details of system services, use sudo. The ps manual runs to more than 2,000 lines, and this guide has covered only the most-used fraction of it: selection, formatting, sorting, trees, and states. The rest — security contexts (-Z, -M), real-time priorities (rtprio), and scheduling classes — can wait until the day you genuinely need to know "which core is this process on, and what priority does it have." By then you will know what to look for.
Here is a cheat sheet to keep by hand: ps for your own processes; ps -ef or ps aux for the whole system; ps -p <PID> for one specific process; ps -C <name> to find by name; ps --forest for parent-child relationships; ps -eo pid,ppid,%mem,comm --sort=-%mem for memory ranking; ps -o pid= for headerless output in scripts; when you see D state, do not rush to kill — it is waiting on I/O, kill will not move it, so wait for the I/O or find the storage cause; when you see Z state, look at the PPID column, because that parent is the process to fix.
Boundary note: this guide covers only ps (process snapshots and queries), based on the man7.org ps(1) manual and the procps-ng upstream documentation, in an environment running procps-ng 4.0.4. The demo script demo284_ps.sh ends by printing --- done (all demo processes killed) ---, confirming every sleep and bash process it started is killed, leaving nothing behind. It is distinct from previously published guides as follows: the ss guide covers sockets and network connections, not process selection; the df guide covers disk space, not processes; the free guide covers total memory and the meaning of available, while the %MEM column here covers only how much one process uses, not how system memory is accounted for; the lsof guide covers the files processes have open; and the journalctl guide covers log queries — the history of processes ps cannot see belongs to it. top has no guide of its own — it is the "live broadcast" version of ps, mentioned here only where snapshot versus live matters, and its interactive operation is not covered. The demo script demo284_ps.sh and its transcript demo284_ps_transcript.txt are delivered with this guide; the script exits 0, and the sleep and bash processes it starts are all killed when it ends, leaving nothing behind.
Why does one command have three different option styles in the first place? The answer is history. Unix split early into two families: System V, whose ps took dash options like -ef, and BSD, whose ps took bare letters like aux. GNU's procps, the version Linux ships, decided to be compatible with both, and then added its own long options on top. The manual is honest about the cost of that decision: options of different types may be mixed freely, but conflicts can appear, and some synonymous options exist only because several standards and implementations had to be accommodated. That is why ps -ef and ps aux look like two different commands wearing one name — because, historically, they are. The practical rule is simple: pick one style per command and stay in it. Use Unix style (-ef, -o, --sort, --forest) when you want precise control, and BSD style (aux, axjf) when you want a quick, familiar listing. Mixing them in one command works until it does not, and the failure mode is silent: you get output that looks right but selected a different set of processes than you meant. When a ps command surprises you, the first thing to check is which style you actually typed.
One more worked example ties the whole guide together: a runaway process is eating CPU, and you need to stop it without breaking anything else. First, find it: ps -eo pid,ppid,%cpu,etime,comm --sort=-%cpu | head -5 shows the top CPU users, and the ETIME column tells you whether it just started or has been running for hours. Second, identify it: read the full command line with ps -o args= -p <PID> — a process named python3 could be anything, and the command line tells you which script it is. Third, find its family: ps --forest -o pid,ppid,comm -p <PID> --ppid <PID> shows its parent and children, so you can tell whether killing this one process will orphan children that keep running. Fourth, choose the target: if the process is a child that went wrong, kill the child by PID; if the parent keeps spawning replacements, the parent is the problem, and killing children one by one will never end. Fifth, check the result: run ps -p <PID> again — empty output means it is gone — and run ps --ppid <parent> to confirm no children were left behind. Two companion tools are worth knowing here, though they belong to their own guides: pgrep finds PIDs by name so you do not have to parse ps output in a script, and pkill sends a signal by name. But the diagnosis itself — what is running, who started it, what state it is in — is ps's job, and it is the step that decides whether the kill that follows is the right one.
A final portability note: everything in this guide was run on Linux with procps-ng ps. macOS ships the BSD ps, which accepts aux and -ef but not the GNU long options — --forest, --sort, and --ppid will not work there, and the column names after -o differ in places. If you work across both systems, stick to ps -ef, ps aux, and ps -o pid,ppid,stat,comm, which behave the same on both, and keep the Linux-only spellings for Linux machines.

Comments (0)
Sources
Related articles
df says the disk is full; it never says who took the space. du does. This guide runs every command for real on GNU coreutils du 9.4: -sh totals, -d drilling, block rounding (a 100-byte file takes 4.0K), sparse files (100M apparent, 0 on disk), -b vs --apparent-size, --exclude, and the three reasons du and df disagree — plus a full-disk investigation flow.
How many lines, how many words, how many bytes — wc answers all three, and it is easy to get all three wrong. This guide runs every command for real on GNU coreutils wc 9.4: -l counts newlines (not lines), -c and -m diverge on Chinese text, --total=only, multi-file totals, and piping — with output pasted verbatim and the two classic traps explained.
Is there enough memory? free answers the question — and the column most people read is the least useful one. This guide runs every command for real on procps-ng free 4.0.4: total, used, free, shared, buff/cache and available, -w, -t, --si, -s sampling, and a live 200MB allocation that shows the kernel handing cache back. The rule to remember: judge memory by available, never by free.