2.5 Process Control
Every running program is a process with a unique PID (Process ID).
Viewing Processes
Section titled “Viewing Processes”top: Real-time view of system resources (CPU/RAM) and processes. Pressqto quit.htop: A prettier, more interactive version of top (often needs install).ps: Snapshot of current processes.ps aux(BSD style) orps -ef(Standard): Shows ALL processes.
Killing Processes
Section titled “Killing Processes”Creating a “zombie” or stopping a stuck program.
kill <PID>: Send SIGTERM (15). Asks nicely to stop.kill -9 <PID>: Send SIGKILL (9). Forces stop immediately (can lose data).killall <name>: Kill processes by name instead of ID.
Background Jobs
Section titled “Background Jobs”When you run a command, it occupies the terminal.
-
Background (
&):Runs in background. Terminal is free.
-
Foreground (
fg) to Background (bg):- Run a command (e.g.,
top). - Press
Ctrl + Zto suspend it. - Type
bgto resume it in background. - Type
fgto bring it back to foreground.
- Run a command (e.g.,
-
Jobs:
- Type
jobsto list background jobs in current terminal session.
- Type