Linux Command Reference ยท Concepts
Linux process states
Understand Linux process states shown by ps and top: running, sleeping, uninterruptible, stopped and zombie, what each letter means and how to deal with them.
Every Linux process is in exactly one state at any moment: running on a CPU, waiting for something, stopped, or finished but not yet cleaned up. Tools such as ps and top show the state as a single letter, and knowing the letters helps you read a busy system and decide whether a process is healthy, waiting or truly stuck.
The kernel tracks these states for every task. Most processes spend nearly all their time asleep, waiting for input, a timer or a lock, which is why a machine with hundreds of processes can still be idle.
ps -o pid,stat,comm -p $$ # state of the current shell ps -eo stat | sort | uniq -c # how many processes per state
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
The state letters
The first character of the STAT column in ps (and the S column in top) is the main state:
| Letter | Name | Meaning |
|---|---|---|
R |
Running or runnable | On a CPU now, or ready and waiting for one. |
S |
Interruptible sleep | Waiting for an event (input, timer, child). Signals wake it. |
D |
Uninterruptible sleep | Waiting inside the kernel, usually for disk or network I/O. Signals wait until it finishes. |
T |
Stopped | Paused by SIGSTOP, Ctrl+Z (SIGTSTP) or a debugger. |
t |
Tracing stop | Stopped by a debugger or strace. |
Z |
Zombie | Already exited; waiting for its parent to read the exit status. |
I |
Idle kernel thread | A kernel thread with nothing to do (newer kernels). |
X |
Dead | Never seen in practice. |
Extra characters follow the first one in ps:
| Flag | Meaning |
|---|---|
s |
Session leader |
l |
Multi-threaded |
+ |
In the foreground process group of its terminal |
< |
High priority (negative nice) |
N |
Low priority (positive nice) |
L |
Has pages locked in memory |
So Ss is a sleeping session leader (typically a shell), and Sl+ is a sleeping, multi-threaded foreground process.
Life cycle
A new process is created by fork, becomes runnable, and alternates between R and the sleeping states as it computes and waits. When it exits it becomes a zombie until its parent calls wait to collect the exit status. If the parent dies first, the orphan is adopted by PID 1 (init or systemd), which reaps it automatically.
stateDiagram-v2
[*] --> R: fork
R --> S: waits for event
S --> R: event or signal
R --> D: blocks in kernel I/O
D --> R: I/O done
R --> T: SIGSTOP
T --> R: SIGCONT
R --> Z: exit
Z --> [*]: parent calls waitA simplified view of the states a process moves between.
Usage notes
- Zombies use almost nothing. A zombie holds only a process-table entry, not memory. A few are harmless; thousands signal a parent that forgets to
wait. You cannot kill a zombie (it is already dead); fix or restart the parent, or let it exit so PID 1 adopts the zombie. Dis the one to worry about. A process in uninterruptible sleep ignores evenSIGKILLuntil the kernel call returns. Long-lastingDstates usually point to a hung network filesystem or a failing disk. They also count toward the load average, which is why load can be high with idle CPUs.Rdoes not mean "using 100% CPU". It means ready or running. On a busy machine many tasks areRwhile sharing the cores.- Load average counts
RandD. Seeuptimeand/proc/loadavg. Tversus background. Ctrl+Z stops a job (T);bgresumes it in the background;fgbrings it forward. Seebgandfg.- Where the state lives. The kernel exposes it in
/proc/PID/statand/proc/PID/status(theState:line). See/proc/PID. - Filter by state.
ps -eo pid,stat,comm | awk '$2 ~ /^D/'lists blocked processes;ps -eo pid,ppid,stat,comm | awk '$3 ~ /^Z/'lists zombies with their parents. - Threads each have their own state;
ps -Lshows them. The letter for the process shown by default is that of its main thread.