Processes through /proc
Read a running process straight from the kernel: status, open files, memory maps and environment under /proc/<pid>, the D and Z states, and lsof.
Kernel space, user space and system callsThe filesystem hierarchy
Processes through /proc
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- /proc is not on disk. Each read asks the kernel for live data, and tools like ps, top and lsof are mostly readers of /proc.
- /proc/<pid>/status is the human-readable summary: state, parent, UIDs, memory, threads, capabilities, allowed CPUs, context switches.
- /proc/<pid>/fd holds one symlink per open file descriptor, pointing at a path, a socket:[inode] or a pipe. /proc/<pid>/maps lists every mapped region of memory.
- /proc/<pid>/environ is the environment the program started with, not what it holds now, and only the owner or root can read it.
- D is uninterruptible sleep, usually waiting on I/O. A process in D does not react to signals, even SIGKILL, until the wait ends.
- Z is a zombie: finished, but its parent has not collected the exit status. You cannot kill it. Fix or kill the parent, and the zombie is reaped by its new parent.
- `lsof +L1` finds files that were deleted but are still held open, the usual reason df shows a full disk that du cannot account for.
Asking the kernel directly
ps and top show a summary of processes, and the shell-bash lesson on them covers using them. But where does ps get its numbers? Not from some private kernel channel. It opens files under /proc and parses them. You can read the same files, and they hold more than any one tool prints.
/proc is a pseudo-filesystem. Nothing in it is stored on disk. When you cat a file there, the kernel generates the contents at that moment from its own data structures. Think of it as a set of read-only windows into the kernel, labelled like files so every tool that reads files can use them. The computer science lesson on processes and threads has the theory. This one shows where Linux puts it.
Inside /proc/<pid>/
Every process has a directory named after its PID. /proc/self is a link to the directory of whichever process opens it. The files you will use most, all per proc(5) and the proc_pid_* pages in man-pages 6.19:
| File | What it holds |
|---|---|
status |
The readable summary, below |
cmdline |
The full command line, NUL-separated |
exe |
Symlink to the executable, still valid if the file was deleted |
cwd |
Symlink to the working directory |
fd/ |
One symlink per open file descriptor |
maps |
Every memory region, with permissions and backing file |
environ |
The starting environment, NUL-separated |
limits |
Resource limits, the topic of the ulimit lesson |
cgroup, ns/ |
Which cgroup and namespaces it belongs to, two lessons on |
Reading status
This Mac has no /proc, so here is the example from proc_pid_status(5), trimmed:
State: S (sleeping)
Pid: 17248
PPid: 17200
TracerPid: 0
Uid: 1000 1000 1000 1000
FDSize: 256
VmPeak: 131168 kB
VmRSS: 13484 kB
RssAnon: 10264 kB
RssFile: 3220 kB
Threads: 1
CapEff: 0000000000000000
NoNewPrivs: 0
Cpus_allowed_list: 0
voluntary_ctxt_switches: 150
nonvoluntary_ctxt_switches: 545
What each answers. PPid gives the parent. TracerPid is non-zero if something like strace or a debugger is attached. The four Uid columns are real, effective, saved and filesystem UIDs, which differ for setuid programs. VmRSS is memory actually resident, split into anonymous memory and file-backed pages that can be dropped and re-read. CapEff is the effective capability set, all zeros for an ordinary user. NoNewPrivs is 1 under the systemd setting from the sandboxing lesson. A high nonvoluntary_ctxt_switches count means the process is often preempted while it still wants the CPU, a hint of CPU contention.
Open files and memory
ls -l /proc/<pid>/fd shows each descriptor as a symlink. Regular files point at a path. Sockets look like socket:[2248868], where the number is an inode you can find in /proc/net/tcp or with ss -e. Pipes look like pipe:[...]. A file deleted while it is open is still listed there, because the descriptor still refers to it.
That last case is behind a classic incident. A log is deleted to free space, but the process writing it keeps the descriptor, so the blocks are not freed. df reports the disk full, du cannot find the space, because du walks names and the file has none. lsof +L1 lists open files with a link count below one, which per lsof(8) selects open files that have been unlinked. Restarting or signalling the writer releases them. The log rotation lesson showed why that signal is part of rotating logs.
maps shows each region of the address space: address range, permissions (r-xp for code, rw-p for data), offset and the backing file, or [heap], [stack] and [vdso] for special ones. A mapped file that has since been deleted gets (deleted) after its name. It is how you see which shared libraries a running process actually loaded, as opposed to what ldd predicts.
environ holds the environment as it was at execve(). proc_pid_environ(5) says changes the program makes afterwards are not reflected. Reading it is restricted by the same check as attaching a debugger, so you can read your own processes’ environment but not other users’. That matters, because environments often hold secrets.
The states that confuse people
ps shows a state letter from the third field of /proc/<pid>/stat. R running or runnable, S interruptible sleep, T stopped, I idle kernel thread. Two cause most questions.
D, uninterruptible sleep. The process is inside the kernel waiting for something it cannot abandon halfway, usually disk or network-filesystem I/O. Signals wait until it returns, so kill -9 appears to do nothing. A few processes flickering through D is normal. Many stuck in D for minutes points at storage: a dying disk, a hung NFS server. On Linux, D-state processes also count toward the load average, which the load average lesson returns to.
Z, zombie. The process has exited. All that remains is an entry holding its exit status until the parent collects it with wait(). It uses no memory or CPU, only a PID. You cannot kill a zombie, because it is already dead. If a parent never collects its children, kill or fix the parent. The zombies are then reparented to PID 1 or a subreaper, which reaps them.
I made one on this Mac with a Python script that forks a child, lets the child exit, then waits half a second before reaping it. macOS, not Linux, but ps uses the same letter:
PID PPID STAT UCOMM
23555 23553 S Python
23556 23555 Z Python
after waitpid:
PID PPID STAT UCOMM
Once the parent calls waitpid(), the zombie is gone.
About the video
The embed is a clip, 5:37 to 15:50, of That DevOps Guy’s (Marcel Dempers) “Understanding Linux Processes”, November 2026. The clip’s chapters are “The Process /proc directory”, pgrep, top, foreground and background processes, process states, the zombie state and orphan processes. The opening ps chapters and the closing signals chapters are cut, because the shell-bash lessons already cover them. From the chapter list it does not go into status fields, fd, maps or lsof, which is where this lesson spends most of its time. English was judged from the channel and the English auto-caption track. I judged it from chapters, not a full watch.
What was run: the zombie demo on macOS. Everything about /proc is from man-pages 6.19 and the kernel’s /proc documentation, checked 2026-11-28, because there is no Linux machine here.
Where this fits
Every process in R is competing for a CPU. How Linux decides who runs, and how you tilt it, is next: scheduling, priorities and nice.
Check yourself
`df` says /var is 100% full, but `du -sh /var` adds up to half that. What is the likely cause and how do you find it?
A process still holds open a large file that was deleted, so its space is not freed. `lsof +L1` lists open files with no remaining links. Restarting or signalling that process frees the space.
You change an environment variable in a running service's config and check /proc/<pid>/environ. It shows the old value. Why?
environ shows the environment from when the program was executed. The process has to be restarted to get the new one.
`kill -9` does nothing to a process in state D. Why?
It is in an uninterruptible wait inside the kernel, typically on disk or network storage. Signals are delivered only when the wait ends, so the fix is whatever unblocks the I/O.
There are 300 zombie processes, all with the same parent. What do you do?
Zombies already exited and cannot be killed. The parent is not calling wait(). Fix or restart the parent. When it dies, the zombies are reparented and reaped by init or a subreaper.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.