Chapter 9. Processes and Resource Control
Every program you run - a shell command, the SSH daemon, a database - is a process: an execution of a program with an identity, a state, open files, and claims on the machine's CPU, memory, and storage. The kernel arbitrates those claims. It decides which task runs on which CPU and for how long, it decides which block requests reach the disk first, it reclaims memory under pressure, and it can fence off whole groups of processes with cgroups so that one workload cannot starve the rest. This chapter works that machinery from the ground up: how to inspect processes and their file descriptors, how to stop programs cleanly and keep interactive work alive, how CPU scheduling and CPU allocation actually behave on Debian 13, how the block layer schedules I/O and what you can control, how memory and swap behave under pressure, how to apply limits at the shell, login, and service level, and how to investigate a process that is stuck or out of control.
The examples run on one Debian 13 system: a small virtual machine with two
CPUs and 1.4 GiB of RAM, kernel 6.12.86+deb13-amd64, systemd 257.13,
procps 4.0.4, util-linux 2.41, tmux 3.5a, strace 6.13, stress-ng 0.19.02,
and sysstat 12.7.5. That hardware shape shows up in the numbers - every
capture in the chapter depends on it. Your process IDs, timestamps, and disk
figures will differ. Commands entered in john's ordinary shell begin with
$, commands entered in a root shell begin with #, and a single
elevated command is written $ sudo command; the prompt marker is not typed.
John's account and his sudo access were established during installation in
Chapter 2 (Chapter 5
covers granting them); when a procedure says "in the root shell", enter
sudo -i from john's shell and leave that shell with exit. Each console
block shows one command (or one explicitly bounded sequence) followed by its
own output; where a capture is shortened, the text says what was omitted.
Chapter 3 covered the shell itself - streams,
redirections, pipes, and job control - and Chapter 8
covered systemd units, systemctl show, drop-ins, and the journal; both are
assumed from here on.
Example files that belong to john live under
~/debian-handbook/processes, created the first time they are needed; the
block I/O section also prepares a second, disposable disk (/dev/vdb)
formatted with ext4 and mounted at /mnt/io-lab. The exercises use a few
packages beyond a minimal installation - tmux, strace, stress-ng,
sysstat, and fio - installable in the usual way with
$ sudo apt install tmux strace stress-ng sysstat fio.