ps Command Guide for a Snapshot of Running Processes
This guide helps you understand and use the ps command, the standard way to report what processes are running on your system right now.
What is ps, and Why Use It?
The ps command prints a snapshot of the processes the system knows about — their IDs, what they are doing, how much memory they use, and who started them. Its name literally means “process status.” Unlike top, which keeps refreshing, ps shows you one frozen moment and exits.
Why Learn ps?
- The first move when something is wrong: “What is actually running?” is always the first debugging question.
- Portable:
psworks the same on virtually every Unix-like system, even wheretopbehaves differently. - Scriptable: Its output is plain text, perfect for piping into
greporawk. - It teaches you the PID: Every other process tool —
kill,pkill,renice— works from the process IDspsreveals.
psis a photograph, not a video. If you need to watch a process change over time, usetoporhtopinstead.
1. The Classic ps aux
ps aux
a— show processes for all users.u— show output in user-oriented format (who owns it, CPU%, memory%).x— include processes not attached to a terminal (daemons and background services).
The output columns are:
| Column | Meaning |
|---|---|
USER | Who started the process. |
PID | Process ID — the number every other tool uses. |
%CPU | Share of CPU used (an average since start, not instantaneous). |
%MEM | Share of physical memory in use. |
VSZ | Virtual memory size, in KB. |
RSS | Real (physical) memory size, in KB. |
TTY | Which terminal it is attached to (? means none). |
STAT | Process state (R running, S sleeping, Z zombie, …). |
START | When it started. |
TIME | Total CPU time consumed. |
COMMAND | The command line that started it. |
To find a specific process in a long list, pipe it:
ps aux | grep firefox
2. The Modern ps Format
The BSD-style options (aux) are historic. Modern ps uses its own flag names, which are easier to remember:
ps -ef
-e— every process.-f— full-format listing (adds PPID, start time, and the full command).
ps axjf
j— adds job control info (session and parent process IDs), which makes it easy to see which shell started which program.
3. Show Only Your Own Processes
ps
With no options, ps lists only the processes attached to your current terminal. That is often enough to find the program you just launched:
ps -l
-l— the long “linux format”, showing UID, PPID, nice value, and state flags.
4. Find a Process by Name
Combine ps with grep:
ps aux | grep nginx
That shows any running nginx processes. A common refinement:
ps aux | grep [n]ginx
The bracket trick stops grep from matching its own command line in the output. When a process is not there, that line disappears — which is itself useful information.
5. Watch a Process Change
ps -p 1234 -o pid,pcpu,pmem,cmd
-p 1234— restrict to PID 1234.-o ...— choose exactly the columns you want.
Re-running this every few seconds (or wrapping it in watch later in this book) is a lightweight way to poll a single process without launching a full top session.
Common Pitfalls
ps auxvsps -efis not the same list.ps auxcan miss processes without a controlling terminal on some systems;ps -efcan miss session details. When in doubt, useps auxfor a general scan orps -effor parent-child relationships.%CPUinpsis an average since the process started, not what it is using this second. A process can show 0% here and still be busy right now — that istop’s job.- The
COMMANDcolumn is truncated in the default format. Useps -eforps auxwwfor the full command line. grepmatches itself (ps aux | grep fooalso lists thegrepprocess). Use the bracket trick[f]ooor switch topgrep.- Zombie processes (
Zstate) are not really running. They are dead entries waiting for their parent to read their exit status; you cannot kill them directly — seekill.
Related Pages
| Page | Relationship |
|---|---|
top | Live, updating view of processes instead of a snapshot. |
htop | Colorful interactive alternative to top. |
pgrep | Find process IDs by name without parsing ps output. |
kill | Send signals to the PIDs ps reveals. |
jobs | The shell’s own list of background jobs. |
ps Cheatsheet
| Command | What It Does |
|---|---|
ps aux | All processes, user-friendly format. |
ps -ef | Every process, full-format listing. |
ps axjf | Process tree with job-control info. |
ps | Processes attached to your terminal. |
ps aux | grep [n]ginx | Find processes matching a name. |
ps -p 1234 -o pid,pcpu,cmd | Chosen columns for one PID. |
ps aux --sort=-%mem | head | Top memory consumers. |
ps auxww | Full command lines, not truncated. |