Running a Linux machine means dealing with stuck or runaway programs from time to time. When a program stops responding or eats up too many resources, you need to end it. This guide walks you through how to Linux kill process by name using simple terminal commands.
You will learn how to find active programs and stop them without tracking down their process IDs first.
Understanding Running Programs on Your System
Every program you launch on Linux creates a running instance called a process. The operating system assigns each one a unique Process ID (PID) to track and control it.
Sometimes a program hangs or hogs your CPU and memory. Try a gentle stop request or restart first. Forcing a close should be your last option.
Locating the Target Program
Before you Linux kill process by name, confirm it is active. The ps command paired with grep works well for this.
To spot all running instances of firefox:
ps aux | grep firefox
ps aux displays every active program. grep filters results to show only matching entries.
Using pkill to Linux Kill Process By Name
The kill command expects a PID as input. If you want to skip looking up the PID, use pkill instead.
With pkill, you Linux kill process by name directly:
pkill firefox
This ends all matching instances. If four browser windows are open, every one of them shuts down.
Signal Types for Greater Precision
Linux lets you choose how a program gets stopped. Two common signal types are:
| Signal | Number | Behavior |
|---|---|---|
| SIGTERM | 15 | Asks the program to shut down gracefully |
| SIGKILL | 9 | Forces an immediate stop with no cleanup |
SIGTERM is the default. It gives the program a chance to save data and exit cleanly. SIGKILL forces a stop with no cleanup. Use it only when SIGTERM fails.
To send SIGTERM:
pkill -SIGTERM firefox
If that fails, force it with SIGKILL:
pkill -SIGKILL firefox
Using killall as an Alternative
The killall command works similarly to pkill but requires an exact match on the program name:
killall firefox
pkill matches partial names, while killall matches the full name only. If “app” and “app-helper” are both running, pkill app stops both. killall app stops only the exact match.
Quick Reference for Linux Kill Process By Name
| Task | Command |
|---|---|
| List active programs | ps aux |
| Search for a specific program | ps aux | grep [name] |
| End a program by its name | pkill [name] |
| Graceful shutdown by name | pkill -SIGTERM [name] |
| Forced shutdown by name | pkill -SIGKILL [name] |
| Kill exact name match | killall [name] |
FAQs
What is the difference between pkill and killall?
pkill matches partial process names and supports pattern matching. killall requires the exact process name. Both send SIGTERM by default and can target multiple instances at once.
Can I Linux kill process by name without root access?
You can end processes you own without root. To stop processes owned by other users or system services, you need sudo or root privileges.
Is SIGKILL safe to use?
SIGKILL forces an immediate stop without letting the program save data or clean up. It can cause file corruption or data loss. Always try SIGTERM first.
How do I kill a process running in the background?
Use pkill or killall with the program name. Background processes respond to the same signals as foreground ones. You can also use ps aux to find and verify them first.
What happens if pkill matches the wrong process?
pkill matches partial names, so it can stop unintended programs. Use pgrep with the -l flag first to preview matches before running pkill to avoid mistakes.