Linux Kill Process: Stop Processes by PID or Name

When a Linux app freezes or a background command stops responding, closing the window is not always enough. The process can keep running, hold files open, or block you from starting the program again.
Linux gives you several ways to stop it manually. Use kill when you know the process ID (PID), killall when you know the exact process name, and pkill
when you want to match a name, user, or command pattern.
This guide explains how to kill a process in Linux by PID or name, how signals work, and when to use SIGTERM or SIGKILL.
Regular users can terminate only their own processes. The root user, or a user running commands with sudo, can terminate processes system-wide. The commands shown here work on any Linux distribution.
Quick Reference
For a printable quick reference, see the kill cheatsheet .
| Command | Description |
|---|---|
kill PID | Send SIGTERM to a process by PID |
kill -9 PID | Force kill a process by PID |
killall name | Send SIGTERM to all processes with an exact name |
killall -u user name | Kill matching processes owned by a user |
pkill name | Kill processes that match a name pattern |
pkill -u user name | Kill matching processes owned by a user |
xkill | Click a graphical window to close it |
Understanding Kill Signals
kill, killall, and pkill send a given signal to specified processes or process groups. If no signal is specified, they default to 15 (TERM) for a graceful shutdown.
Common signals include:
1(HUP) - Reload configuration for daemons that support it.9(KILL) - Force immediate termination. Use it as a last resort.15(TERM) - Gracefully stop a process. This is the default signal.
Signals can be specified in three different ways:
- Using a number, such as
-1 - With the
SIGprefix, such as-SIGHUP - Without the
SIGprefix, such as-HUP
Use the -l option to list all available signals:
kill -l # or killall -l
Using the kill Command
To terminate a process with the kill
command, you first need to find its PID. You can do this using different commands, such as top, ps
, pidof, and pgrep
.
For example, use ps to search for a running Firefox process:
ps aux | grep firefoxIf Firefox has become unresponsive, find its process IDs with the pidof
command:
pidof firefoxThe command prints all matching Firefox PIDs:
2551 2514 1963 1856 1771Start with the default TERM signal so the process has a chance to exit cleanly:
kill 2551 2514 1963 1856 1771If the process ignores TERM, send the KILL signal:
kill -9 2551 2514 1963 1856 1771SIGKILL cannot be caught or ignored, so it stops the process immediately. Use it only when the normal kill PID command does not work.
Using the killall Command
The killall command terminates all processes matching a given name. This is useful when a program has multiple running instances and you do not want to copy several PIDs.
Using the same scenario as before, send SIGTERM to all Firefox processes:
killall firefoxIf Firefox still does not close, force it to stop:
killall -9 firefoxkillall accepts several options, such as sending signals to processes owned by a specific user, matching process names against regular expressions, and filtering by process age. You can get a list of all options by typing killall --help in your terminal.
For example, to terminate Firefox processes owned by the user zoe, run:
sudo killall -u zoe firefoxUsing the pkill Command
pkill
terminates processes that match the pattern given on the command line:
pkill firefoxThe process name does not have to be an exact match. Partial matches work too, which makes pkill flexible but also easier to misuse.
Before using a broad pattern, preview the matches with pgrep
:
pgrep -a firefoxTo kill only Firefox processes owned by the user zoe, run:
pkill -u zoe firefoxIf the process does not stop, add -9:
pkill -9 -u zoe firefoxUsing xkill for GUI Applications
If a graphical application becomes unresponsive, you can use xkill to terminate it by clicking on its window:
xkillAfter running the command, your cursor changes to an “X”. Click on the window you want to close, and the application will be terminated.
xkill works only on X11 sessions. On Wayland, which is now the default on recent Ubuntu and Fedora releases, it cannot close native Wayland windows. Use pkill, killall, or the desktop system monitor instead.Troubleshooting
Process will not die with -9
If a process does not terminate even with SIGKILL (-9), it may be a zombie process. Zombie processes are already dead but still appear in the process table because their parent has not read their exit status.
To find zombie processes:
ps aux | awk '$8 ~ /Z/'You cannot kill a zombie directly. Instead, kill its parent process or restart the system.
Permission denied
If you get a “Permission denied” error, the process belongs to another user. Use sudo to terminate it:
sudo kill PIDIf the process still does not stop, use sudo kill -9 PID.
Conclusion
To kill a process in Linux, use kill PID when you know the process ID, killall name for an exact process name, or pkill pattern when you need flexible matching. Start with the default SIGTERM signal, then use SIGKILL only when the process refuses to exit.
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