Mastering Linux killall: How to Safely Terminate Processes with Advanced Options
Learn how to effectively use the Linux killall command to terminate processes, including basic usage, case‑insensitive matching, interactive prompts, quiet mode, signal selection, and handling long‑named processes, with step‑by‑step examples and visual illustrations.
Linux's command line offers many commands to kill processes.
For example, you can pass a PID to the kill command, or use pkill with a regular expression to terminate matching processes.
The killall command, by default, matches the exact name of the process and kills it.
Linux killall command
The killall command can send a signal to a specific process. By default the signal is SIGTERM, but other signals can be specified with options.
Below are practical examples of using this command.
1. Basic example
Assume there are two processes whose names start with the same characters.
How to kill the test_again process?
As shown, killall terminates test_again. You can verify with ps:
The test_again process no longer appears because it has been killed.
2. Using the -I option to ignore case
By default, killall is case‑sensitive. For example:
The command cannot find a process named TEST, but the test process is running.
To make killall ignore case, use the -I option (capital i):
Now the test process is successfully terminated.
3. Using the -i option for interactive termination killall can terminate multiple processes.
To terminate processes interactively, use the -i option. Example:
This allows the user to confirm each termination when multiple processes are targeted.
4. Using the -q option to suppress output
When killall cannot find the specified process, it prints an error message.
To run killall quietly, use the -q option:
After applying -q, the command's output is suppressed.
5. Using the -l option to list all supported signals
You can send a specific signal with -s followed by the signal name.
To see all available signals, use the -l (lowercase L) option:
killallsupports all of these signals.
A fun little question
The man page for killall states that if a process name is 15 characters or fewer, it matches the full name by default.
Consider two processes with long names:
The first process name has exactly 15 characters. Using killall successfully kills it:
If both process names exceed 15 characters, killall will kill both according to the man page. Example:
When attempting to kill the second long‑named process, only the specified one is terminated:
Version information of the killall command used in the experiment:
Can you guess why this issue occurs? Feel free to leave a comment below.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
