Software & OS

ps aux Explained: How to Read Linux Process Output

ps aux prints a snapshot of every process on a Linux system, one per line, with its owner, process ID, CPU and memory use, state, start time and full command. The three letters mean a = processes of all users, u = the user-oriented column layout, and x = include processes that have no terminal, such as services.

ps aux

What a, u and x mean (and why there is no dash)

ps on Linux (the procps-ng version) accepts three option styles: Unix options with a dash (-ef), BSD options without a dash (aux), and GNU long options with two dashes (--sort). aux is BSD style, so the letters are written together with no dash:

  • a lifts the BSD default of showing only your own processes.
  • u switches to the "user-oriented" format, which adds the USER, %CPU, %MEM, VSZ, RSS and START columns.
  • x lifts the default that a process must be attached to a terminal. Without it, daemons such as cron and sshd don't appear.

You will see ps -aux in old tutorials. It usually works, but the ps(1) manual says commands like ps -aux "are not recommended as it is a confusion of two different standards". Write ps aux.

How to read each column

Example output from Ubuntu 22.04 (procps-ng 3.3.17), shortened:

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1 18.8  0.0 165784 11112 ?        Ss   13:27   0:00 /sbin/init
root          39  6.2  0.0  31344 11652 ?        S<s  13:27   0:00 /lib/systemd/systemd-journald
root         187  0.0  0.0   4304  2632 ?        Ss   13:27   0:00 /usr/sbin/cron -f -P
root         204  5.0  0.1 2132844 40160 ?       Ssl  13:27   0:00 /usr/lib/snapd/snapd
alex         455  0.0  0.0   4780  3348 pts/0    Ss+  13:27   0:00 bash
ColumnMeaning
USERThe account the process runs as.
PIDProcess ID. This is the number you pass to kill.
%CPUCPU time used divided by the time the process has been running, as a percentage. It is a lifetime average, not current load, and the column does not add up to 100%.
%MEMRSS as a share of the machine's physical memory.
VSZVirtual memory size in KiB: everything the process has mapped, including shared libraries and memory it reserved but never touched.
RSSResident set size in KiB: the non-swapped physical memory the process is actually using.
TTYThe controlling terminal. ? means none, which is normal for services.
STATProcess state code (next section).
STARTWhen the process started: a time for today, a date for older processes.
TIMETotal CPU time consumed, not wall-clock time.
COMMANDThe command with its arguments. Names in square brackets, such as [kworker/0:1], are kernel threads with no command line.

This snapshot was taken seconds after the system booted, which is why /sbin/init shows 18.8% CPU: it did most of its work in the first moments of a very short lifetime, and %CPU averages over that lifetime. The same process would show close to 0.0 an hour later.

VSZ almost always looks alarming. In the output above, snapd has a VSZ of 2,132,844 KiB (about 2 GiB) but an RSS of 40,160 KiB (about 39 MiB). RSS is the column to watch when you are hunting for what is eating your RAM, and %MEM is derived from it.

What the STAT codes mean

The first letter is the state. Any letters after it are extra flags that only BSD-format output (like aux) shows.

CodeMeaning
RRunning or runnable (waiting for a CPU)
SInterruptible sleep: waiting for an event, such as input or a timer. Most processes are in this state most of the time.
DUninterruptible sleep, usually waiting on I/O. Many D processes at once often point to a slow or hung disk or network mount.
IIdle kernel thread
TStopped by job control (for example, after Ctrl+Z)
tStopped by a debugger during tracing
ZZombie: the process has exited but its parent has not collected its exit status yet
< / NHigh priority / low priority (nice)
sSession leader
lMulti-threaded
+In the foreground process group of its terminal

So Ssl on snapd reads as: sleeping, session leader, multi-threaded. Ss+ on the shell means sleeping, session leader, running in the foreground of pts/0.

How to find a specific process

The common habit is piping into grep:

ps aux | grep cron

Example output:

root         187  0.0  0.0   4304  2632 ?        Ss   13:27   0:00 /usr/sbin/cron -f -P
alex         460  0.0  0.0   4024  1996 pts/0    S+   13:27   0:00 grep cron

The second line is grep finding itself, because its own command line contains "cron". Two ways to avoid it:

ps aux | grep '[c]ron'
pgrep -a cron

The bracket pattern [c]ron still matches "cron", but the literal text [c]ron in grep's command line no longer matches. pgrep -a is cleaner: it prints the PID and full command line of each match (here, 187 /usr/sbin/cron -f -P). Add -f to match against the whole command line instead of just the process name, and -u alex to limit it to one user.

How to sort ps aux by memory or CPU

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

The minus sign reverses the order, so the biggest consumers come first; head -n 6 keeps the header plus the top five. Remember that %CPU is a lifetime average, so a process that started a second ago and is spinning flat out can rank below a long-running one. For what is busy right now, use top (press M to sort by memory, P for CPU).

How to show only the columns you need

The -o option takes a comma-separated list of columns. Combined with -e (every process) it replaces aux entirely:

ps -eo pid,ppid,stat,comm

Example output, shortened:

    PID    PPID STAT COMMAND
      1       0 Ss   systemd
     39       1 S<s  systemd-journal
     60       1 Ss   systemd-udevd

ppid is the parent's process ID, which aux does not show, and comm is the short process name (use cmd or args for the full command line). To look at one program by name, use -C, and add etime for the wall-clock time since it started:

ps -o pid,stat,etime,cmd -C cron

Example output:

    PID STAT     ELAPSED CMD
    117 Ss         00:08 /usr/sbin/cron -f -P

Long command lines are cut at the terminal width. Add w twice for unlimited width: ps auxww.

How to find zombie processes

ps -eo pid,ppid,stat,cmd | awk '$3 ~ /^Z/'

A zombie has already exited; all that is left is its slot in the kernel process table, which stays until the parent collects the exit status with a wait call. There is nothing left to kill. If zombies pile up, the parent (the PPID column) is the process with the bug. Stopping or restarting that parent clears them: its zombie children are adopted by init (PID 1), which waits on them automatically. The force-quit guide covers stopping a process safely with kill and when to escalate to kill -9.

If the process you expect isn't listed

First check spelling with pgrep -af and part of the name, because the COMMAND column shows the executable path, which may differ from the package name (the Docker daemon is dockerd, for example). If it still isn't there, the program has exited: for a service, systemctl status <name> shows whether it crashed and the last log lines. Inside a container, ps aux lists only that container's processes; run it on the host to see everything.

Frequently asked questions

What is the difference between ps aux and ps -ef?
Both list every process on the system. ps aux uses BSD-style options (no dash) and shows %CPU, %MEM, VSZ, RSS and the STAT column. ps -ef uses Unix-style options and shows UID, PID, PPID, start time and the command, which makes it handier when you need the parent process ID. Pick whichever columns you need; the process list is the same.
Why does ps aux | grep show the grep command itself?
grep is running while ps takes its snapshot, so its own command line (which contains your search word) appears in the list. Use pgrep -a name instead, or write the pattern as grep [n]ame: the bracket pattern still matches 'name' but no longer matches its own command line.
Does ps aux show live CPU usage?
No. The %CPU column is the CPU time a process has used divided by how long it has been running, so it is an average over the process lifetime. A program that was busy for a second an hour ago and idle since will show a low number. For live usage, use top or htop.
Why does a command appear in square brackets in ps output?
When ps cannot read a process's arguments it shows the executable name in brackets instead. On Linux you mostly see this for kernel threads such as [kthreadd] or [kworker/0:1], which have no command line.

Sources