🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

kill Command

Beginner Process Management man(1)

Send signals to processes (terminate, stop, continue)

👁 12 views 📅 Updated: Mar 15, 2026
SYNTAX
kill [SIGNAL] PID...

What Does kill Do?

The kill command sends signals to processes, most commonly used to terminate them. Despite its name, kill can send any signal, not just termination signals. Signals are the primary inter-process communication mechanism in Unix/Linux.

The most important signals are SIGTERM (15, graceful shutdown), SIGKILL (9, force kill), SIGHUP (1, reload configuration), and SIGSTOP/SIGCONT (pause/resume). SIGTERM is the default and allows processes to clean up before exiting.

kill requires the process ID (PID). Use ps, pgrep, or pidof to find PIDs. For killing by name instead of PID, use killall or pkill.

Options & Flags

OptionDescriptionExample
-15 / -TERM Send SIGTERM — graceful termination (default) kill 1234
-9 / -KILL Send SIGKILL — force kill (cannot be caught) kill -9 1234
-1 / -HUP Send SIGHUP — reload configuration kill -HUP 1234
-STOP Pause a process kill -STOP 1234
-CONT Resume a paused process kill -CONT 1234
-l List all signal names kill -l
-0 Check if process exists (no signal sent) kill -0 1234 && echo "running"

Practical Examples

#1 Graceful termination

Sends SIGTERM — the process can catch this and clean up before exiting.
$ kill 1234

#2 Force kill

Sends SIGKILL — immediately terminates the process. Use only when SIGTERM fails.
$ kill -9 1234

#3 Reload configuration

Sends SIGHUP to nginx — causes it to reload its configuration without restarting.
$ kill -HUP $(cat /var/run/nginx.pid)

#4 Kill multiple processes

Sends SIGTERM to multiple processes at once.
$ kill 1234 5678 9012

#5 Kill all user processes

Terminates all processes owned by a specific user.
$ kill $(ps -u baduser -o pid=)

#6 Check if process exists

Signal 0 checks process existence without actually sending a signal.
$ kill -0 1234 2>/dev/null && echo "Running" || echo "Not running"

#7 List all signals

Shows all available signal names and numbers.
$ kill -l
Output: 1) SIGHUP 2) SIGINT 9) SIGKILL 15) SIGTERM

Tips & Best Practices

Try SIGTERM before SIGKILL: Always try kill PID (SIGTERM) first. Only use kill -9 if the process does not respond. SIGKILL prevents cleanup and can leave corrupted data.
Kill by name: Use killall processname or pkill processname instead of finding the PID first. More convenient for most cases.
Signal 0 for checking: kill -0 PID does not send a signal — it just checks if the process exists and you have permission to signal it. Useful in scripts.

Frequently Asked Questions

What is the difference between kill and kill -9?
kill sends SIGTERM (signal 15) — the process can catch it and exit gracefully. kill -9 sends SIGKILL — the kernel immediately terminates the process with no chance to clean up.
How do I find the PID to kill?
Use ps aux | grep name, pgrep name, or pidof name to find the PID. Then kill PID.
Why does kill sometimes not work?
The process may be in uninterruptible sleep (state D) or be a zombie. For zombies, kill the parent process. For D-state, the process is waiting for I/O to complete.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →