Linux killall Command: Signal Processes by Name

Linux's killall sends signals to processes that match the specified name. The default is SIGTERM, and if there are multiple processes with the same name, they can all be targeted.

This explanation is based on the common psmisc implementation in Linux. The meaning of killall can be different in other Unix variants, so always check the current manual when moving between systems. Target selection is first reviewed with pgrep.

Basic syntax

killall [option] name...

Installed implementations and options may vary depending on the distribution. Check the current system description with man killall.

Examples

Checking for processes with the same name

First, look at the PID and command line of the intended name.

pgrep -a -x myworker

Requesting normal termination

In the Linux psmisc implementation, SIGTERM is sent to jobs whose names match.

killall -TERM myworker

Target name and user restrictions

Use this when you need to reduce the user scope.

killall -u alice myworker

When there are multiple processes with the same name

killall can send a signal to all processes that match the specified name. You should first check the candidates with pgrep to avoid terminating unexpected instances.

pgrep -a -x demo-worker
killall -TERM demo-worker

The first command shows the target PID and command line, while the second command usually does not output anything even if successful. After that, check the remaining processes with pgrep -a -x demo-worker. If there are multiple processes with the same name, they can all be affected.

Replace the example name with the test process you created. Some Unix-based killall implementations behave differently from Linux, so do not assume portability. If the target is a service, using systemctl stop service-name may be more appropriate than directly terminating the process.

Main Options and Format

Options/Format Description
-s signal Specifies the signal to send.
-u user Selects only the processes of the specified user.
-i Prompts for confirmation for each target.
-v Displays detailed execution information.
-w Waits until the matched processes terminate.

Precautions when using

Be especially careful on shared servers, as using only the name may affect all processes with the same name. -w may wait a long time for processes that do not terminate. The behavior of killall on other operating systems may differ, so do not confuse it with the Linux psmisc implementation.

Frequently Asked Questions

Does killall terminate all processes on the system?

In the Linux psmisc implementation, it targets processes that match the specified name. However, in other Unix implementations, the meaning can be different.

Official Documentation

The exact behavior of the options and implementation differences can be found in the official killall documentation.