killall

On this page 7

killall is a Linux command-line utility that sends a signal to all processes matching a name, rather than to a single process ID. Within the Processes topic of Linux administration, it is the quickest way to stop, reload or inspect every running instance of one program with a single command.

On Linux, killall comes from the psmisc package and matches processes by their command name by default. It sends SIGTERM unless another signal is requested, which makes it a name-based counterpart to kill and a stricter, more predictable relative of pkill.

How killall selects and signals processes

killall works by scanning the process table exposed in /proc, comparing each process name with the argument, and delivering the chosen Unix signal to every match. The command name it compares is the short name stored in /proc/PID/stat, which the kernel truncates to 15 characters.

Because the short name can be ambiguous, killall falls back to the full executable path when a name is longer than 15 characters and a match would otherwise be uncertain. When the argument contains a slash, such as /usr/sbin/nginx, killall matches only processes running that exact file, which is the safest way to target a specific binary.

The sequence below shows what happens during a typical invocation, from parsing the arguments to reporting the result through the exit status.

StageWhat killall doesRelevant detail
Parse argumentsReads names, signal and filtersDefault signal is SIGTERM
Read process tableWalks every directory in /procRequires readable process entries
Match namesCompares the command name or pathExact match unless -r is used
Apply filtersChecks user, age and terminal optionsOptions -u, -o, -y narrow the set
Deliver signalCalls kill() for each matched PIDPermission errors are reported
Report resultReturns exit status 0 or 11 means no process was killed
Stages of a killall invocation

Key killall options and signals

The most useful killall options narrow the selection or change the signal, and knowing them prevents accidental termination of unrelated processes. The signal is given as -s NAME, -SIGNAL or a number, and killall -l lists all signal names the system supports.

OptionEffectTypical use
-s or -SIGNALSends the named signalReload a daemon with HUP
-iAsks for confirmation per processInteractive cleanup on shared hosts
-u userMatches only that user’s processesStop one account’s sessions
-eRequires an exact long-name matchAvoid 15-character ambiguity
-IIgnores case in namesInconsistent program naming
-rTreats the name as a regular expressionMatch a family of workers
-o and -ySelects processes older or younger than a timeKill only stale instances
-wWaits until all matched processes exitScripts that restart a service
-qSuppresses messages when nothing matchesQuiet automation
Frequently used killall options

The choice of signal decides whether the program can clean up. SIGTERM and SIGHUP can be caught and handled, while SIGKILL cannot be caught or ignored, so the kernel removes the process immediately without flushing buffers or deleting lock files.

SignalNumberTypical meaningCan be handled
SIGTERM15Request a graceful shutdownYes
SIGHUP1Reload configuration in many daemonsYes
SIGINT2Interrupt, as with Ctrl+CYes
SIGKILL9Terminate immediatelyNo
SIGSTOP19Pause executionNo
SIGCONT18Resume a paused processYes
Signals commonly sent with killall

killall compared with kill and pkill

killall differs from kill and pkill mainly in how it identifies targets: kill needs process IDs, pkill matches a pattern anywhere in the name, and killall requires an exact name match by default. That strictness makes killall less likely to hit an unintended process whose name merely contains the search string.

CommandSelects processes byDefault matchingSource package
killProcess ID or job numberNo name matchingutil-linux or shell built-in
pkillName, user, group or full command lineRegular expression substringprocps-ng
killallCommand name or executable pathExact namepsmisc
pgrepSame criteria as pkillRegular expression substringprocps-ng
Comparison of process termination commands

A practical rule follows from this: use kill when the PID is known, killall when every instance of a named program must receive the same signal, and pkill when the match depends on command-line arguments. A dry run with pgrep or killall -i is a sensible check before a destructive signal.

Portability and the Solaris pitfall

killall is not portable across Unix systems, and the difference is serious. On Solaris and some older System V derivatives, a command named killall terminates all active processes as part of the shutdown sequence, so running a Linux habit there can stop an entire server.

Even among Linux distributions the tool may be absent from minimal container images, where psmisc is often not installed. Scripts intended to run in many environments therefore check for the command or prefer pkill, which ships with the more widely installed procps-ng package.

Common mistakes when using killall

Most killall problems arise from matching the wrong set of processes or from using an overly forceful signal. The table lists frequent symptoms with their usual causes and remedies.

SymptomLikely causeFix
No process foundName differs from the visible titleCheck the real name with ps -e
Long name does not matchKernel truncates names to 15 charactersUse -e or the full path
Operation not permittedProcesses belong to another userRun with sufficient privileges
Data or lock files left behindSIGKILL used as the first choiceSend SIGTERM and wait first
Unrelated sessions closedShared program name across usersAdd -u to limit the scope
Process survives SIGKILLUninterruptible sleep or zombie stateFix the I/O wait or the parent
Typical killall problems and fixes
  • Escalate gradually: send SIGTERM, wait a few seconds, and use SIGKILL only for processes that remain.
  • Zombie processes cannot be killed because they have already exited; the parent must reap them, or the parent itself must end.
  • Avoid running killall as root casually, because it then matches the processes of every user on the system.
  • Prefer service managers such as systemctl for managed daemons, so that restart policies and dependencies stay consistent.

Explained without jargon

Every program running on a Linux computer is a process, and each one has a name. killall lets an administrator address all processes with the same name at once, much like calling everyone named Alex in a crowded room instead of tapping each person on the shoulder.

Usually the message is a polite request to finish up and leave, which gives the program time to save its work. If a program refuses to respond, a much stronger message can remove it instantly. The key takeaway is simple: killall is fast and convenient, so it is worth checking exactly which programs share that name before using it.

A typical use case

A systems administrator manages a web server where a deployment script has left twelve stalled worker processes named report-worker, each holding about 400 MB of memory. Restarting the whole machine would interrupt the web service, so the administrator first lists the workers with pgrep -l report-worker and confirms that all of them belong to the app account.

The administrator then runs killall -u app -w report-worker, which sends SIGTERM to every matching worker and waits until they exit. Ten processes stop within two seconds; two remain stuck. A follow-up killall -u app -9 report-worker removes them. The result is roughly 4.8 GB of memory recovered with no interruption to the web service, and the job scheduler starts fresh workers on its next cycle.