To kill all processes with a given name, run pkill NAME or killall NAME. To kill all processes owned by one user, run pkill -u USER from another account. Both send SIGTERM, so programs can clean up; add -9 only if a process is still there a few seconds later. Avoid kill -9 -1: it sends SIGKILL to every process you may signal, which normally ends your own session, and as root it reaches everything except PID 1. I preview every pattern with pgrep -a first; it only lists matches.
I checked the claims here against the kill(1), kill(2), signal(7), pkill(1) and killall5 man pages and source; I did not run these commands on a Linux machine.
Table of Contents
Which command kills what
| To kill | Use | Watch out for |
|---|---|---|
| Every process with a name | pkill -x NAME or killall NAME |
Names are cut at 15 characters |
| Processes with TEXT in the command line | pkill -f TEXT |
Also matches tail -f TEXT.log and similar |
| Everything one user owns | pkill -u USER or killall -u USER |
Signals your own session if USER is you |
| A systemd service | systemctl kill UNIT |
Restart= can start it again |
| A frozen desktop app | Resources, System Monitor or xkill |
xkill only reaches X11 apps |
| Everything you own | kill -9 -1 |
Normally ends your session; as root, all but PID 1 |
Kill all processes by name with pkill or killall
pgrep -a firefox # preview what pkill firefox would hit
pkill firefox # SIGTERM to every process whose name contains "firefox"
pkill -x firefox # exact name only
killall firefox # exact name too (package psmisc)
pkill -f 'app.py' # match the full command line instead
pkill reads its pattern as an extended regular expression and matches it anywhere in the name, so short patterns match too much. killall compares whole names unless you add -r. Linux records a process name as the executable’s file name cut to 15 characters, so python3 app.py is called python3, and pkill in procps-ng 4.0 and later warns when a longer pattern matches nothing. The fix is -f, which matches the full command line, so pkill -f app.py also kills tail -f app.py.log.
pkill never matches itself, but it can match its parents: in sudo pkill -f app.py, sudo’s own command line contains the pattern. Add -A to skip ancestors. It needs procps-ng 4.0.1 or later: Ubuntu 24.04 and 26.04 ship 4.0.4, while 22.04 ships 3.3.17, which predates it.
Kill all processes owned by one user
pgrep -a -u alice # what alice is running
sudo pkill -u alice # SIGTERM to every process alice owns
sudo killall -u alice # same; killall's name argument is optional
sudo loginctl terminate-user alice # systemd: end all of alice's sessions
I run these from another account: pointed at yourself, pkill -u "$USER" signals your own terminal, SSH session and desktop along with everything else. kill has no user option, so kill -u alice is an error. loginctl kill-user sends a signal (SIGTERM by default) to all of a user’s processes, and terminate-user kills all processes of all the user’s sessions. As with any pkill, send SIGTERM first and -KILL only to what survives.
What kill -9 -1 does
In kill -9 -1, -9 is the signal and -1 is the PID. The kill(2) man page defines -1 as “every process for which the calling process has permission to send signals, except for process 1 (init)”. A PID of 0 means your own process group, and -1234 means process group 1234 (give a signal or -- first so it is not read as an option).
On Linux the calling process is exempt, so the shell that ran the builtin is not signalled directly. Everything around it is: your terminal emulator, the process carrying your SSH connection and your desktop session all run as you. The window closes or the connection drops, and the shell exits when it loses its terminal. killall5 (package sysvinit-utils) signals everything outside your own session, but its man page says its only use is in rc scripts, so I treat it as the same hazard.
Send SIGTERM first, then SIGKILL
kill, pkill and killall send SIGTERM unless you name another signal. A program can catch SIGTERM, flush its buffers and remove its lock and temp files; SIGKILL cannot be caught, blocked or ignored (signal(7)), so none of that happens and a stale lock file can block the next start. The util-linux kill(1) man page says to prefer TERM and use KILL only if the process does not terminate. I do it in two steps:
pkill -x myapp
sleep 5
pgrep -x myapp && pkill -KILL -x myapp
For the single-process case, and telling a stuck process from a slow one, there is a separate guide. I put the pkill -f over-matching and the SIGTERM-versus-SIGKILL clean-up difference in a script you can run against scratch processes it creates and removes: verify-kill-all-processes.sh.
Kill all processes of a service with systemctl kill
sudo systemctl stop myapp.service # SIGTERM, then SIGKILL after the timeout
sudo systemctl kill myapp.service # SIGTERM to every process of the unit
sudo systemctl kill --signal=SIGKILL myapp.service # force it
sudo systemctl kill --kill-whom=main myapp.service # main process only (--kill-who before systemd 252)
By default systemctl stop sends SIGTERM and follows with SIGKILL once TimeoutStopSec= has passed (systemd.kill(5)). I use systemctl kill when a stop hangs or I want a specific signal. --kill-whom takes main, control or all, plus cgroup from systemd 258 on, and all is the default (systemctl(1)). If the unit sets Restart=, a process killed by a signal can be started again, while systemctl stop keeps a service down (systemd.service(5)).
Kill an application on Ubuntu
Click the frozen window and wait about five seconds: GNOME Shell then offers Force Quit next to Wait. Otherwise use your release’s system monitor:
- Ubuntu 26.04 LTS: open Resources (1.10.2), which replaced System Monitor. Choose Apps, select the application and click End App. If it stays, right-click the app, or open the arrow beside the button, and choose Kill App.
- Ubuntu 24.04 LTS and 22.04 LTS: open System Monitor, go to the Processes tab, select the process and click End Process. If it survives, right-click it and choose Kill… (plain Kill on 22.04).
End App and End Process send SIGTERM, Kill App and Kill send SIGKILL, and each asks you to confirm first. xkill (package x11-utils) closes the X server connection of the window you click; many apps exit when that happens and some keep running. It only reaches apps connected to the X server, which on a Wayland session means those running through XWayland, and Ubuntu’s desktop session has been Wayland-only since 25.10.