0 / 15 lessons — 0%
Lesson 03 / 15
Process management & systemd
Every running program is a process, identified by a PID. ps and top/htop are how you see what's actually running and how much of the machine it's using.
ps aux # every process, full detail ps aux --sort=-%cpu # sorted by CPU, worst offender first top # live, refreshing view (htop if installed — nicer) pgrep nginx # find PIDs by name kill 4821 # ask a process to terminate gracefully (SIGTERM) kill -9 4821 # force-kill, no cleanup (SIGKILL) — last resort
Most services you'll manage don't run as bare processes though — they're wrapped by systemd, the init system on nearly every modern Linux distro. systemd starts services at boot, restarts them if they crash, and manages dependencies between them.
sudo systemctl status nginx sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl enable nginx # start automatically on boot sudo systemctl disable nginx journalctl -u nginx -f # follow that service's logs live
| systemctl state | Meaning |
|---|---|
active (running) | Working normally, process alive |
inactive (dead) | Not currently running |
failed | It tried to start and crashed, or exited with an error |
enabled / disabled | Whether it auto-starts at boot — independent of its current running state |
"Enabled" and "running" are two different questions — a service can be enabled (will start on boot) but currently stopped, or running right now but not enabled (won't survive a reboot).
systemctl status shows both on separate lines.Try it yourselfRun
systemctl list-units --type=service --state=running to see everything systemd currently has alive on your machine — usually a longer list than people expect.