Processes and Signals
When something is broken, one of the first questions is: what process is actually running, and what state is it in?
Core commands
Section titled “Core commands”ps aux # list running processes with CPU and memory usageps -ef | grep <name>pgrep -a <name> # find matching PIDs and print their command linestophtop # friendlier interactive process viewkill <pid>kill -TERM <pid> # ask a process to exit cleanlykill -KILL <pid> # force-kill a processkill -HUP <pid> # tell some daemons to reload configSignal cheat sheet
Section titled “Signal cheat sheet”| Signal | Meaning | Typical use |
|---|---|---|
TERM |
Ask process to exit cleanly | Normal stop |
KILL |
Force immediate stop | Last resort |
HUP |
Hangup or reload | Re-read config for some daemons |
INT |
Interrupt | Similar to Ctrl+C |
Useful reads
Section titled “Useful reads”ps -p <pid> -o pid,ppid,user,%cpu,%mem,stat,start,time,cmd # detailed view for one PIDcat /proc/<pid>/status # kernel-exposed process statustr '\0' ' ' < /proc/<pid>/cmdline # print the full command line cleanlyreadlink -f /proc/<pid>/cwd # show the process working directorySTAT matters. A process in D state is stuck in uninterruptible sleep, often on disk or kernel I/O. Z means zombie.
Practical rule
Section titled “Practical rule”If systemd owns the process, use systemctl restart <service-name> instead of killing the PID directly. Otherwise systemd may just bring it back and you learn nothing.
Common mistake
Section titled “Common mistake”Do not jump straight to kill -9. Try a normal stop first so the process can flush state, close files, and log a useful error.