$_ CLI In Depth
Learning progress 0%
lesson processes signals job-control

What Is a Process: PID, PPID & State

6 min read Module 10: Processes, Signals & Job Control Updated Dec 5, 2026
Cheat Sheet
0:00 / 3:22

A program is not a process

A program is a file that contains machine code and data, such as /bin/sleep. Nothing happens when the file sits on disk. The kernel creates a process when something asks it to run that file. The process gets its own virtual memory, its own table of open file descriptors, a current directory, a set of credentials, and a unique number called the process ID, or PID.

The same program can run many times at once. Two terminals that each run sleep 100 create two processes from one file. They share the code pages of the program in memory, but each process has separate variables, separate file descriptors, and separate state. Killing one of them does not affect the other.

PID, PPID and the process tree

Every process except the very first one has a parent. The parent process ID, or PPID, is the PID of the process that created it. Processes started from your shell have your shell as their parent. Your shell was started by the terminal emulator or the login program, and the first process in the system, PID 1, is started by the kernel itself.

Because each process records its parent, the whole system forms a tree. Look at any process and you can walk up the tree to find where it came from. Look at a process you want to stop and you can find the shell or service that started it. The tree is also why a parent can clean up after its children, a point the later units in this module return to when they describe fork, wait, and zombies.

Process states

At any moment the kernel records a state for each process. The most common states are shown in the STAT column of ps, with one letter each:

  • R means running or runnable: the process is on a CPU or waiting in line for one.
  • S means interruptible sleep: the process is waiting for an event, such as keyboard input or a timer. Most shells and idle programs are in this state.
  • D means uninterruptible sleep, usually waiting for disk I/O. A process in D state cannot be killed until the I/O finishes.
  • T means stopped, for example by Ctrl-Z or SIGSTOP.
  • Z means zombie: the process has exited, but its parent has not yet collected its exit status.

Extra letters follow the main one. A lowercase s means the process is a session leader, and a + means it is in the foreground process group of its terminal. A typical interactive shell shows Ss, which means a sleeping session leader.

Keep the difference between a process and its state in mind when you read the table. The process is the thing, and its state is a snapshot of what the kernel is doing with it at that instant. A shell that is waiting for your next key and a shell that is running a long pipeline are the same process in two different states. A single reading is therefore a sample, and a single sample can mislead you. When you need to know whether something is stuck or merely busy, take two or three readings a second apart and compare them.

PIDs are also reused. When a process ends, the kernel eventually gives its number to a new process, so a PID you wrote down earlier may now belong to something else. Scripts that save a PID to a file should check the command name as well as the number before they send a signal. The later lessons in this module use that check whenever they stop a job.

Keep the difference between a process and its state in mind when you read the table. The process is the thing, and its state is a snapshot of what the kernel is doing with it at that instant. A shell that is waiting for your next key and a shell that is running a long pipeline are the same process in two different states. A single reading is therefore a sample, and a single sample can mislead you. When you need to know whether something is stuck or merely busy, take two or three readings a second apart and compare them.

PIDs are also reused. When a process ends, the kernel eventually gives its number to a new process, so a PID you wrote down earlier may now belong to something else. Scripts that save a PID to a file should check the command name as well as the number before they send a signal. The later lessons in this module use that check whenever they stop a job.

Looking at your own shell

The shell variable $$ expands to the PID of the current shell. It is the quickest way to get a PID you know is alive, because the shell is running the line you are typing. The next command shows the PID, the parent, the state, and the command name for that one process.

BASH2 lines
echo $$
ps -o pid,ppid,stat,comm -p $$

The -p option restricts the output to the PIDs listed after it. The -o option chooses the columns. The comm column is the short command name, usually the file name of the program, and it is limited to 15 characters. The args column shows the full command line instead.

The kernel exposes the same facts through the /proc file system. Each process has a directory named after its PID, and the file status in that directory holds a readable summary. The next command selects three of its fields from the shell itself.

BASH1 lines
grep -E "^(Name|State|PPid)" /proc/$$/status

The Name line gives the command name, State gives the state with a description in parentheses, and PPid gives the parent. The values match what ps printed, because both tools read the same kernel data.

Note

The state changes from moment to moment. A shell that shows S is not idle in a hidden way. It is sleeping in a read call, waiting for your next keystroke, and the kernel wakes it when the key arrives.

Hands-on: read your process tree

Run the commands below in the lab. The first prints the PID of your shell. The second prints the same shell with its parent and state. The third prints the state from /proc, which you can compare with the STAT column.

BASH3 lines
echo "shell pid is $$"
ps -o pid,ppid,stat,comm -p $$
grep State /proc/$$/status

The PID numbers differ from run to run, so do not memorize them. The pattern is what matters. The PPID of your shell is the PID of whatever started it, and the state column for an idle shell shows S. In the next unit you will list every process on the system and find these same relationships among the others.

Parents, children and process states

Visualizer

Every process has a PID and a parent PID. Follow fork, exec and wait, then see how a zombie and an orphan show up in ps.

1 / 5
ps -eo pid,ppid,stat,comm (illustrative values)
PIDPPIDSTATCOMMAND
41204101Sbash

Every process has a PID and a PPID, the PID of its parent. For example, the interactive shell here is PID 4120. It sleeps (state S) while it waits for your next line.

echo "shell $$"; sh -c 'echo "child $$, parent $PPID"'; echo "shell waited, status $?"
Terminal lab · 2 steps · real Linux in your browser

Find a process and its parent

Start a background subshell, save its PID, and read its parent and state from ps.

01
Start a background subshell
A subshell is a bash process that has not replaced itself with another program. Parentheses create one. The trailing true keeps bash from replacing itself with sleep, so the subshell stays a bash process. ``bash ( sleep 300; true ) & echo $! > sub.pid `` After you run these two lines, the file sub.pid holds the PID of the subshell. The ampersand starts it in the background, and $! is the PID of the most recent background job.
Show hint for step 1
Put an ampersand after the closing parenthesis, then send $! into sub.pid. Run both lines in /workspace.
02
Read the parent and state of the subshell
Ask ps for the PPID and the STAT of the subshell, with the header turned off, and save the line in sub-info.txt. The PPID is the process that started the subshell. The state should start with S, because the subshell is asleep while sleep runs. ``bash ps -o ppid=,stat= -p "$(cat sub.pid)" > sub-info.txt `` Open the file with cat sub-info.txt to see the two values.
Show hint for step 2
Use -o ppid=,stat= so ps prints only the two columns with no header. Redirect the output to sub-info.txt.
Check yourself Question 1 of 4
Concept Check Waiting for disk I/O recall

Which STAT letter in ps output marks a process in uninterruptible sleep, usually waiting for disk I/O?

Recap & Key Takeaways

A program is a file, and a process is a running instance of it with its own PID, memory, and file descriptors.
Every process records its parent PID, so the processes on a system form a tree that starts at PID 1.
The STAT column shows the state: R running, S sleeping, D waiting for disk, T stopped, and Z zombie.
The shell variable $$ gives your shell PID, and ps -p or /proc/PID/status show its state and parent.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue