🔧 Tools & Platforms
Linux Process Management
Every running program on a Linux system is a process — an instance of an executable with its own memory space, file descriptors, and process ID (PID). Bresnahan and Blum explain the process lifecycle from creation (fork/exec) through execution to termination, and the tools for monitoring, controlling, and prioritizing processes. Understanding process management is essential for diagnosing performance problems, managing server workloads, and ensuring critical services stay running. A process is not the same as a program: a single program can spawn multiple processes, and understanding this distinction is key to managing Linux systems effectively.
2
Minutes
2
Concepts
+45
XP
1
How It Works
- Process lifecycle and PIDs — Every process has a unique PID assigned by the kernel. PID 1 is the init system (systemd on modern distros). New processes are created by forking an existing process (parent) and optionally replacing its image with a new program (exec). Each process has a parent PID (PPID), forming a tree visible with
pstree.
- Monitoring with ps and top — Two essential tools:
ps aux— snapshot of all running processes with user, PID, CPU%, MEM%, commandps -ef— full-format listing with PPID relationshipstop/htop— real-time, updating view of processes sorted by resource usage- Key top columns: PID, USER, PR (priority), NI (nice value), VIRT/RES/SHR (memory), %CPU, %MEM, COMMAND
- Signals and kill — Processes communicate through signals. The
killcommand sends signals by PID:
SIGTERM(15) — polite termination request; process can clean up:kill PIDSIGKILL(9) — forced termination; no cleanup:kill -9 PIDSIGHUP(1) — hangup; many daemons reload config on SIGHUP:kill -HUP PIDSIGSTOP(19) — pause process:kill -STOP PIDSIGCONT(18) — resume paused process:kill -CONT PIDkillall— kill by name:killall nginxpkill— kill by pattern:pkill -f "python script.py"
- Background and foreground jobs — The shell manages jobs:
command &— start in backgroundCtrl+Z— suspend foreground processbg— resume suspended process in backgroundfg— bring background process to foregroundjobs— list current shell jobsnohup command &— run process that survives shell exit
- Priority and nice values — Linux schedules CPU time based on priority. Nice values range from -20 (highest priority) to 19 (lowest). Regular users can only increase nice (lower priority); root can decrease it.
nice -n 10 command— start with lower priorityrenice -n 5 -p PID— change priority of running process