How to Use the kill Command in Linux

Sometimes applications stop responding or consume too many system resources, and a normal exit no longer works. The kill command terminates these processes by sending them a signal, from a graceful shutdown request to an immediate force kill.
There are several utilities that allow you to terminate errant processes, with kill being the most commonly used.
kill Command
kill is a shell built-in in most Bourne-derived shells such as Bash and Zsh. The command behavior is slightly different between the shells and the standalone /bin/kill executable.
Use the type
command to display all locations on your system containing kill:
type -a killkill is a shell builtin
kill is /bin/killThe output above shows that the shell built-in has priority over the standalone executable, and it is used whenever you type kill. If you want to use the binary, type the full path to the file /bin/kill. In this article, we will use the Bash built-in.
The syntax of the kill command takes the following form:
kill [OPTIONS] [PID]...The kill command sends a signal to specified processes or process groups, causing them to act according to the signal. When the signal is not specified, it defaults to -15 (-TERM).
The most commonly used signals are:
1(HUP) - Hangup, often used by daemons to reload configuration.9(KILL) - Kill a process immediately.15(TERM) - Gracefully stop a process.
To get a list of all available signals, invoke the command with the -l option:
kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERMSignals can be specified in three different ways:
- Using number (e.g.,
-1or-s 1). - Using the “SIG” prefix (e.g.,
-SIGHUPor-s SIGHUP). - Without the “SIG” prefix (e.g.,
-HUPor-s HUP).
The following commands are equivalent to one another:
kill -1 PID_NUMBER
kill -SIGHUP PID_NUMBER
kill -HUP PID_NUMBERThe PIDs provided to the kill command can be one of the following:
- If
PIDis greater than zero, the signal is sent to the process with ID equal to thePID. - If
PIDis equal to zero, the signal is sent to all processes in the current process group. In other words, the signal is sent to all processes belonging to the PGID of the shell that invoked thekillcommand. Use theps -efjcommand to view process group IDs (PGIDs). - If
PIDis equal to-1, the signal is sent to all processes the caller has permission to signal, except special system processes such as PID 1. - If
PIDis less than-1, the signal is sent to all processes in the process group with PGID equal to the absolute value of thePID.
Regular users can send signals to their own processes, but not those that belong to other users, while the root user can send signals to other users’ processes.
Terminating Processes Using the kill Command
To terminate or kill a process
with the kill command, first you need to find the process ID number (PID). You can do this using different commands such as top, ps
, pidof and pgrep
.
For example, you can use ps to find the PID for a running process:
ps aux | grep firefoxLet’s say the Firefox browser has become unresponsive, and you need to kill the Firefox process. To find the browser PIDs use the pidof
command:
pidof firefoxThe command will print the IDs of all Firefox processes:
6263 6199 6142 6076Once you know the PIDs, you can kill all of them by sending the KILL signal:
kill -9 6263 6199 6142 6076Instead of searching for PIDs and then killing the processes, you can combine the above commands into one:
kill -9 $(pidof firefox)Reloading Processes Using the kill Command
Another common use case for kill is to send the HUP signal to daemons that handle it as a reload request.
For example, to reload Nginx
, you need to send a signal to the master process. The process ID of the Nginx master process can be found in the nginx.pid file, which is typically located in the /var/run directory.
Use the cat
command to find the master PID:
cat /var/run/nginx.pid30251Once you find the master PID, reload the Nginx settings by typing:
sudo kill -1 30251The command above must be run as root or user with sudo privileges.
SIGTERM vs SIGKILL
When terminating processes, you should first try SIGTERM (-15), which allows the process to clean up and exit gracefully. If the process does not respond, use SIGKILL (-9), which forces immediate termination.
# Try graceful termination first
kill -15 PID
# If process does not stop, force kill
kill -9 PIDSIGKILL cannot be caught or ignored by the process, so it is the strongest termination signal. However, it does not allow the process to save data or clean up, and some process states, such as uninterruptible sleep or zombies waiting to be reaped, may not disappear immediately.
Check if a Process Exists
Use signal 0 to check whether a PID exists without sending a real signal:
kill -0 PIDKill Processes by Name
Instead of finding the PID first, you can kill processes by name using pkill
or killall.
To kill all Firefox processes by name:
pkill firefoxOr using killall:
killall firefoxThe difference is that pkill matches partial names by default, while killall requires the exact process name.
Killing Background Jobs
If you have background jobs running in the current shell, you can kill them using the job number instead of the PID:
kill %1To list all background jobs and their numbers, use the jobs command:
jobs[1]+ Running sleep 1000 &
[2]- Running sleep 2000 &Troubleshooting
kill: (PID): No such process
The process already exited or the PID is wrong. Re-check with ps -p PID or pgrep name before retrying.
kill: (PID): Operation not permitted
You do not own the target process. Re-run with sudo if the process belongs to root or another user.
Process keeps running after kill -15
Some processes ignore SIGTERM or cannot handle it while busy in uninterruptible system calls. Try kill -9 PID to request forced termination, but note that the process cannot clean up and data may be lost.
Killed wrong PID and shell now hangs
If you accidentally killed your shell or a parent process, open a new terminal session and use pgrep to verify the target before retrying.
Quick Reference
For a printable quick reference, see the kill cheatsheet .
| Command | Description |
|---|---|
kill PID | Send SIGTERM to process |
kill -9 PID | Force kill process |
kill -15 PID | Gracefully terminate process |
kill -1 PID | Reload process configuration |
kill -l | List all signals |
kill %1 | Kill background job number 1 |
pkill name | Kill processes by name |
killall name | Kill all processes with exact name |
FAQ
What does kill -9 do?
It sends SIGKILL, which immediately terminates the process. The kernel handles the signal directly, so the process cannot catch, block, or ignore it.
What is the difference between kill and killall?kill accepts a PID and signals one process. killall accepts a process name and signals every process matching that name.
Why is kill -9 not recommended as the first choice?SIGKILL skips cleanup. The process cannot flush buffers, save state, or release locks, which may corrupt data or leave stale lock files behind.
Can a regular user kill any process?
No. A user can only signal processes they own. Killing other users’ processes requires sudo or running as root.
How do I kill a process by name instead of PID?
Use pkill name for partial name matches or killall name for an exact match. Both accept the same signal flags as kill.
Conclusion
The kill command is used to send signals to processes in Linux. Always try SIGTERM (-15) first for graceful termination, and use SIGKILL (-9) only when necessary.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page