Lesson 9.3: Signals: kill, killall and pkill
What a signal is, the important ones (SIGTERM, SIGKILL, SIGINT, SIGHUP, SIGSTOP, SIGCONT) and their numbers, ending a process politely with kill and by force with kill -9, why some processes ignore SIGTERM, permissions when signalling other users' processes, killing by name with killall and pkill, and making a daemon reload its configuration with SIGHUP.
20 min
You will learn to
- Explain what a signal is and name the common ones
- End a process with SIGTERM and, only if needed, SIGKILL
- Explain why SIGKILL is the last resort
- Signal other users' processes with sudo
- Kill processes by name with killall and pkill
- Reload a daemon with SIGHUP
Key terms
- Signal
- A small numbered message the kernel delivers to a process. The process can run a handler for it, ignore it, or take the default action (usually: end).
- SIGTERM (15)
- 'Please terminate.' The default of kill. Can be caught, so programs can save state and exit cleanly.
- SIGKILL (9)
- 'Stop now.' Can't be caught or ignored; the kernel removes the process immediately. Last resort.
- SIGINT (2)
- Interrupt: what Ctrl+C sends to the foreground program.
- SIGHUP (1)
- 'Hang up': originally the terminal line was disconnected. Daemons use it as 'reload your configuration'.
- SIGSTOP (19) and SIGCONT (18)
- Pause a process (uncatchable, like SIGKILL) and let it continue. Ctrl+Z sends the catchable SIGTSTP (20).
- kill, killall, pkill
- kill sends a signal to PIDs; killall to processes with an exact name; pkill to processes matching a pattern. Despite the name, all of them can send any signal.
← Monitoring the system: top, uptime and free · All lessons · Foreground and background jobs →