How to Use killall Command in Linux: Syntax and Examples
The
killall command in Linux terminates processes by their name instead of process ID. Use killall process_name to stop all processes matching that name quickly and easily.Syntax
The basic syntax of killall is simple and consists of the command followed by options and the process name.
killall [options] process_name: Sends a signal to all processes matchingprocess_name.- Options can modify behavior, like specifying the signal to send.
bash
killall [options] process_name
Example
This example shows how to use killall to stop all running instances of firefox by name.
bash
killall firefox
Output
firefox: no process found
Common Pitfalls
Common mistakes include:
- Using
killallwithout root privileges when required, causing failure to kill some processes. - Typing the wrong process name, which results in no processes being killed.
- Not specifying the correct signal if the default
SIGTERMdoes not stop the process.
Always double-check the process name and consider using -9 option to force kill if needed.
bash
killall wrongname
killall -9 firefoxOutput
killall: no process found
Quick Reference
| Command | Description |
|---|---|
| killall process_name | Kill all processes with the given name using SIGTERM |
| killall -9 process_name | Force kill all processes with SIGKILL signal |
| killall -u username process_name | Kill processes by name owned by a specific user |
| killall -q process_name | Quiet mode, no output |
| killall -v process_name | Verbose mode, shows what is killed |
Key Takeaways
Use
killall process_name to terminate all processes by name quickly.Specify signals like
-9 to force kill if normal termination fails.Ensure you have the right permissions to kill the target processes.
Double-check the process name to avoid killing unintended processes.
Use options like
-u to target processes by user.