How to Use the pkill Command in Linux

pkill is a command-line utility that sends signals to the processes of a running program based on given criteria. The processes can be specified by their full or partial names, a user running the process, or other attributes.
The pkill command is part of the procps (or procps-ng) package, which is pre-installed on nearly all Linux distributions. pkill and pgrep use the same matching rules; pgrep
lists matching processes, while pkill sends signals to them.
How to Use the pkill Command
The syntax for the pkill command is as follows:
pkill [OPTIONS] <PATTERN>The matching <PATTERN> is specified using extended regular expressions.
When invoked without any option, pkill sends the 15 (TERM) signal to the PIDs of all running programs that match the given name. For example, to gracefully stop all Firefox processes, you would run:
pkill firefoxThe command returns 0 when at least one running process matches the requested name. Otherwise, the exit code
is 1. This can be useful when writing shell scripts.
Before using a broad pattern, preview matches with pgrep -a pattern.
To send a different signal to the matched processes, invoke the pkill command with the --signal option, followed by either the numeric or the symbolic signal name. Another way to send a signal is to run pkill followed by the signal name or number prefixed by a hyphen (-).
Use the kill -l
command to list all available signals.
The most commonly used signals are:
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
For example, to reload the Nginx processes you would run:
pkill -HUP nginxpkill uses regular expressions to match the process names. It is always a good idea to use the pgrep command to print the matched processes before sending signals to them. For instance, to list all processes that contain “ssh” in their names:
pgrep -a ssh1039 sshd: /usr/sbin/sshd -D
2257 ssh-agent -s
6850 ssh user@example.com
31279 ssh-agent -sIf you want to send a signal only to the processes whose names are exactly as the search pattern, use the -x option:
pkill -x sshYou can also use regular expression anchors:
pkill '^ssh$'^) character matches at the beginning of the string, and the dollar $ at the end.By default, pkill matches only against the process name. When the -f option is used, the command matches against full argument lists. If the command contains spaces, quote the entire command:
pgrep -af "ping 8.8.8.8"
pkill -f "ping 8.8.8.8"Use -9 only if the process does not stop after the normal TERM signal.
Use the -u option to tell pkill to match processes being run by a given user:
pkill -u mark firefoxTo specify multiple users, separate their names with commas:
pkill -u mark,danny firefoxRunning pkill -u mark without a pattern can signal every process owned by mark, including shells and background jobs.
You can also combine options and search patterns. For example, to send KILL signal to all processes that run under user “mark” and contain “gnome” in their names:
pkill -9 -u mark gnomeTo display only the least recently (oldest) or the most recently (newest) started processes, use the -n (for newest) or the -o (for oldest) option.
For example, to kill the most recently created screen :
pkill -9 -n screenCase-Insensitive Matching
By default, pkill performs case-sensitive pattern matching. To match process names regardless of case, use the -i option:
pkill -i firefoxThis will match “firefox”, “Firefox”, “FIREFOX”, and any other case variation.
Killing Processes by Terminal
The -t option allows you to send signals to processes running on a specific terminal:
pkill -t pts/1This kills all processes associated with terminal pts/1. You can find terminal names using the who or w command.
Counting Matched Processes
To see how many processes match a pattern without sending any signal, use pgrep with the -c option:
pgrep -c firefox3This shows 3 Firefox processes running.
pkill vs kill vs killall
kill- Sends signals to processes by PID. You need to know the exact process ID.pkill- Sends signals to processes by name pattern. Supports regex and various filters.killall- Sends signals to all processes with an exact name match. Simpler thanpkillbut less flexible.
Use kill when you know the exact PID, pkill when you need pattern matching or filters, and killall for simple exact name matches. For a task-focused walkthrough that puts all three together, see how to kill a process in Linux
.
Quick Reference
For a printable quick reference, see the pkill cheatsheet .
| Task | Command |
|---|---|
| Kill by name | pkill firefox |
| Force kill by name | pkill -9 firefox |
| Reload process | pkill -HUP nginx |
| Kill by user and name | pkill -u username process_name |
| Kill by full command | pkill -f "ping 8.8.8.8" |
| Case insensitive | pkill -i Firefox |
| Kill by terminal | pkill -t pts/1 |
| Kill newest process | pkill -n process_name |
| Kill oldest process | pkill -o process_name |
| List matches first | pgrep -a pattern |
Conclusion
The pkill command is useful when you need to signal processes by name, user, terminal, or full command pattern. Preview matches with pgrep
, use exact or scoped patterns when possible, and use kill
when you already know the exact PID.
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