Linux kill process uses kill PID to send SIGTERM (graceful), kill -9 PID for SIGKILL (force). pkill and killall kill by name. The team that uses SIGTERM first has correct process management; SIGKILL is only for unresponsive processes.
Table of contents
The kill command
kill 1234 # SIGTERM (default)
kill -9 1234 # SIGKILL (force)
The team that uses SIGTERM first has the process clean up resources. SIGKILL is last resort.
Find the PID
pgrep nginx # PIDs of nginx
pidof nginx # PIDs of init-style processes
ps aux | grep nginx
The team that uses pgrep has quick PID lookup.
pkill by pattern
pkill nginx
pkill -f 'python.*myapp'
The team that uses pkill -f has regex matching.
killall
killall nginx
The team that uses killall has fast exact-match kill. pkill is more flexible.
The signals
- SIGTERM (15): graceful. Process can clean up.
- SIGKILL (9): immediate. No cleanup. Cannot be ignored.
- SIGHUP (1): hangup. Often used to reload config (e.g., nginx).
- SIGINT (2): interrupt. Like Ctrl-C.
The team that uses SIGHUP for config reloads has zero-downtime reconfig.
FAQ
What’s the default signal for kill?
SIGTERM (15). The team that doesn’t specify -9 has graceful shutdown.
Can a process catch SIGKILL?
No - the kernel handles it. SIGKILL is unstoppable.
Why does my process keep restarting after kill?
It’s managed by systemd, supervisord, or k8s. The team that kills the daemon, not the process, has clean shutdown.
How do I see what signals a process supports?
kill -l lists signals. cat /proc/<pid>/status | grep Sig shows caught signals for a process.
Can I kill a process by name only?
Yes - pkill nginx or killall nginx. The team that uses these doesn’t need to find PIDs first.
If you are sizing the infrastructure for the kind of project this post covers, the RunxBuild hosting calculator is the right place to model the line items. The compute, the memory, the storage, the bandwidth, the database - each one is a separate number, and the team’s mental model for the platform is the sum of those numbers. The RunxBuild dashboard is where the team sees the actual usage in one place.
Useful related references: