The Linux kill Command: Knowing When and How to Terminate
A runaway process was consuming 100% CPU. I tried Ctrl+C—nothing. The server was unresponsive. My senior admin said "just use kill." Three keystrokes later, the system was fine.
I learned: kill is your emergency brake. Learn to use it properly.
Understanding kill
Default: SIGTERM
kill 12345Sends SIGTERM (15) - polite request to terminate.
Force: SIGKILL
kill -9 12345Sends SIGKILL (9) - instant termination.
Other signals
kill -HUP 12345 # Reload config
kill -STOP 12345 # Pause (not terminate)
kill -CONT 12345 # ResumeProcess States and kill
Zombie processes
Can't kill what's already dead:
ps aux | grep ZZombies show as Z. Parent must reap or be killed.
Uninterruptible processes
Waiting on I/O:
ps aux | grep DD = uninterruptible sleep. Wait for I/O or reboot.
kill Commands That Work
Find PID first
ps aux | grep nginx
kill $(pgrep nginx)Better: use pgrep directly.
Kill multiple PIDs
kill 1234 5678 9012Space-separated list.
Kill all by process name
pkill nginxBy name instead of PID.
Kill all by user
pkill -U www-dataAll processes for user.
Kill by pattern
kill -9 $(pgrep -f "python.*script")Kill Python scripts.
Graceful restart
kill -HUP $(cat /var/run/nginx.pid)HUP triggers config reload.
Signal Reference
| Signal | Number | Use |
|---|---|---|
| SIGHUP | 1 | Reload config |
| SIGINT | 2 | Ctrl+C (interrupt) |
| SIGQUIT | 3 | Core dump |
| SIGKILL | 9 | Force kill |
| SIGTERM | 15 | Polite termination |
| SIGSTOP | 19 | Pause |
| SIGCONT | 18 | Resume |
When to Use Each
SIGTERM (15) - First Choice
kill 12345Allows cleanup - close files, save state.
SIGKILL (9) - Last Resort
kill -9 12345When SIGTERM won't work. No cleanup!
SIGHUP (1) - Reload
kill -HUP 12345For daemons - reloads config.
The kill Command Builder
Building kill commands—the kill Command Builder:
- Signal selector visually
- PID finder built-in
- Safety warnings
Safety Rules
-
Try SIGTERM first — graceful termination.
-
SIGKILL is irreversible — no cleanup.
-
Check what's running — don't kill system processes.
-
PID 1 is init — killing it reboots.
-
Check dependencies — killing DB may break apps.
Lessons Learned
-
pkill is easier — by name instead of PID.
-
Check before killing — ps aux | grep.
-
SIGTERM is default — kill = kill -15.
-
Root can kill anything — but be careful.
-
Zombies need parent — kill parent's PID.
Conclusion: kill Is Your Friend
kill is essential for system administration. Use it wisely.
The kill Command Builder makes selecting signals easy.
