>_cmd.script

killall

Send a signal to all processes matching a name

Processes

By CMD Script Team · 4 min read · Last updated

SYNTAX
killall [OPTIONS] NAME...

Options

Command options and flags
FlagDescription
-9Send SIGKILL instead of the default SIGTERM, force-terminating all matches
-iInteractive mode: ask for confirmation before signaling each matching process
-uOnly match processes owned by a given user, e.g. -u alice
-wWait for all signaled processes to actually terminate before returning
-lList all available signal names
-vVerbose: report whether the signal was successfully sent
-eRequire an exact match of the process name rather than a substring match

Distribution compatibility

  • Ubuntu
  • Debian
  • Fedora
  • Arch
  • macOS (BSD killall, different default behavior — see tips)

What it does

killall sends a signal (SIGTERM by default, same as kill) to every currently running process whose command name matches the name you give it, instead of requiring you to look up and specify a numeric PID. It's especially convenient when several instances of the same program are running (multiple browser tabs' renderer processes, several worker processes of the same script) and you want to signal all of them in one command rather than hunting down each PID individually.

Beginner examples

  • killall firefox — send SIGTERM to every process named firefox
  • killall -9 chrome — force-kill every process named chrome
  • killall -i node — ask for confirmation before killing each matching node process
  • killall -l — list all available signal names
killall -9 chrome

Advanced examples

  • Restrict matching to a specific user's processes: killall -u www-data -9 php-fpm
  • Wait until all matched processes have actually exited before the command returns: killall -w -9 stuck_worker
  • Require an exact name match instead of a substring match: killall -e -9 my-daemon
  • See confirmation of what was actually signaled: killall -v python3
  • Gracefully signal all matches, falling back to force if they don't respond: killall python3; sleep 3; killall -9 python3
killall -w -v -9 stuck_worker

Common mistakes

  • Running killall <name> and accidentally matching more processes than intended because the name is a common substring — e.g. killall python matching every Python-based tool on the box, not just your script.
  • Confusing killall with the killall5 used in some System V-style init shutdown scripts, which is a different tool that kills nearly all processes during shutdown.
  • Assuming killall's exact matching behavior is identical across Linux and macOS/BSD — always verify with -i (interactive/confirm) the first time on an unfamiliar system.
  • Not checking permissions first — killall can only signal processes you own unless run as root, so killall someone_elses_process silently skips processes you lack permission for while still reporting on the ones you do own.

Tips

  • Use -i the first time you run a killall command you're unsure about — it shows you exactly what would be signaled and lets you confirm or skip each one.
  • Combine -u with a name to scope a kill to just one user's processes, avoiding collateral damage on a shared/multi-tenant system.
  • Prefer pkill -f <pattern> over killall when you need to match on the full command line (e.g. a specific script path) rather than just the executable's base name.
  • Use -w when a script needs to be sure processes have actually stopped (not just that the signal was sent) before proceeding to the next step, like restarting a service.

Best practices

  • Default to plain killall <name> (SIGTERM) before reaching for -9, giving matched processes a chance to shut down cleanly, just as with kill.
  • Use -u <user> in shared environments to make sure you only affect processes that belong to the intended account, not similarly named processes owned by others.
  • In automation, prefer explicit, well-scoped matching (-e for exact name, or pkill -f with a precise pattern) over a loose substring match that could catch unrelated processes.
  • Verify what will be killed with -i or a preceding pgrep <name> check before running killall -9 in any environment where an accidental match would be costly.

Try it yourself

A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.

Real-world use cases

  • Restarting all worker processes of a script-based service after a config change: killall -HUP my_worker (if the workers handle SIGHUP) or killall my_worker followed by the service's restart mechanism.
  • Cleaning up every leftover instance of a crashed or hung application (e.g. multiple zombie chrome renderer processes) with a single killall -9 chrome.
  • Ending all instances of a test or batch script running under a specific user account during CI cleanup: killall -u ci-runner -9 test_runner.

Common interview questions

  • What's the difference between kill and killall? kill signals a specific PID; killall signals every process whose name matches the given string, which is more convenient when multiple instances of the same program are running.
  • How would you avoid accidentally killing more processes than intended with killall? Use -i for interactive confirmation, -e for exact name matching instead of substring matching, and/or -u <user> to scope by owner.
  • What's the difference between killall and pkill? Both match by name rather than PID, but pkill supports matching against the full command line (-f), parent process, or terminal using more flexible pattern matching, whereas killall typically matches on the executable's base name.

Frequently Asked Questions

What's the difference between killall and kill?

kill signals a process by its numeric PID. killall signals every process whose command name matches the given name, which is more convenient when you don't know (or don't want to look up) the PID, or when there are multiple instances of the same program running.

What's the difference between killall and pkill?

Both match processes by name rather than PID, but pkill supports richer matching (full command line with -f, user, terminal, parent process) via regular expressions, while killall traditionally matches on the exact executable name (or substring on Linux) and is simpler to use for straightforward cases.

Is killall's behavior the same on macOS as on Linux?

No — this is a well-known gotcha. On Linux, killall <name> matches processes by command name. On macOS/BSD, killall behaves similarly but historically some BSD variants required -y/-o age flags for different semantics; always double-check with killall -l or a dry run (-i) before relying on exact behavior across platforms.

How do I confirm before killing each matching process?

Use -i (interactive): killall -i firefox prompts y/n for every matching process before sending the signal.

Cheat sheet

Download a quick-reference cheat sheet for killall.