At some point, you will likely need to find and kill a process in Linux. Like any operating system, Linux applications can freeze, crash, or become unresponsive. When that happens, the safest approach is to locate and terminate the problematic process rather than restarting your entire system.
Common reasons to kill Linux processes include fixing frozen programs, freeing up system resources, troubleshooting performance issues, and stopping suspicious or unwanted background tasks.
Quick Answer: To kill a process in Linux, first find its PID using ps aux or top, then run kill PID. If the process does not stop, use kill -9 PID to force terminate it. You can also use pkill process_name or killall process_name to stop processes by name.
Kill Processes In Linux

Many users instinctively force a shutdown when a program locks up. This can lead to data loss or file system corruption. A better approach is to terminate only the affected process. If that fails, try a soft reboot. A hard shutdown should always be a last resort.
Why You May Need to Kill Processes in Linux
Understanding when and why to terminate a process helps you manage your system more effectively.
1. Free Up System Resources
Running processes consume CPU, RAM, and I/O. If your system feels slow, identifying and stopping unnecessary processes can quickly improve performance.
2. Stop a Frozen or Unresponsive Program
A hanging application can consume excessive resources or lock up your desktop. Terminating the process restores system responsiveness.
3. Stop Suspicious or Malicious Processes
If you notice unknown processes using high resources, terminating them can help prevent potential security risks.
4. Perform System Maintenance
Some updates, upgrades, or configuration changes require stopping running processes to avoid conflicts.
Bottom line: Knowing how to find and kill processes in Linux is essential for performance tuning, troubleshooting, and system stability.
How to Find Running Processes in Linux
Before you can terminate a process, you need its PID (Process ID).
Using the ps Command
ps aux
Using the top Command
top
Using htop (Easier Interactive Viewer)
The htop command provides a more user-friendly interface than top. It allows you to scroll, search, and kill processes interactively.
htop
Use arrow keys to select a process, then press F9 to kill it.
How to Kill a Process in Linux
Using the kill Command
kill PID
kill 1090
This sends a SIGTERM signal, allowing the process to exit safely.
Force Kill a Process
kill -9 PID
Warning: This sends SIGKILL and may cause data loss or corruption. Use only when necessary.
Kill a Process by Name (No PID Required)
If you do not know the PID, Linux provides commands to kill a process by name. This is often faster and easier when dealing with common applications.
Using pkill (Recommended)
The pkill command searches for processes by name and terminates them.
pkill firefox
Why use pkill:
- Simple and fast
- Matches partial process names
- Commonly available on most Linux systems
Tip:
pkill -f firefox
This matches against the full command line.
Using killall
The killall command terminates all processes that match an exact name.
killall firefox
Key difference:
pkillsupports pattern matchingkillalltargets exact process names
Note: On some systems, killall behaves differently, so verify before using it on critical processes.
Kill Processes Using the GUI (xkill)
If you are using a desktop environment, you can kill a frozen window using xkill.
xkill
Your cursor will turn into a cross. Click any unresponsive window to force it to close.
Best used for:
- Frozen GUI applications
- Desktop environments like GNOME, KDE, XFCE
Kill Multiple Processes
You can terminate multiple processes at once:
kill 1234 5678
Or by name:
pkill process_name
Kill Command Comparison
| Command | Use Case | Requires PID |
|---|---|---|
kill |
Terminate a specific process | Yes |
pkill |
Kill process by name or pattern | No |
killall |
Kill all processes with exact name | No |
xkill |
Close frozen GUI applications | No |
Common Errors When Killing Processes in Linux
While killing processes is straightforward, a few common mistakes can cause confusion or system issues.
1. Permission Denied
If you see a "permission denied" error, the process likely belongs to another user or the system.
kill: (PID) - Operation not permitted
Fix: Use sudo to gain the required privileges:
sudo kill PID
2. Process Not Found
If the process no longer exists, you may see:
kill: (PID) - No such process
This usually means the process has already stopped or the PID changed.
Fix: Run ps aux or top again to verify the correct PID.
3. Using kill -9 Too Quickly
Force killing a process with kill -9 should be a last resort.
Why this matters:
- Prevents proper cleanup
- Can cause data corruption
- May leave temporary files behind
Best practice: Always try kill PID first before using -9.
4. Killing the Wrong Process
Accidentally terminating the wrong process can crash applications or your system.
Fix: Double-check the command before running it:
ps aux | grep process_name
5. killall Behavior Differences
On most Linux systems, killall targets processes by name. However, on some Unix systems it may behave differently.
Tip: Always confirm the command behavior before using it in scripts or on critical systems.
Frequently Asked Questions
What is a PID in Linux?
A Process ID (PID) is a unique number assigned to every running process. It is used to identify and terminate processes.
What is the difference between kill and kill -9?
kill sends SIGTERM for graceful shutdown, while kill -9 sends SIGKILL for immediate termination.
How do I kill a process by name?
Use pkill or killall:
pkill firefox
killall firefox
Is it safe to kill system processes?
No. Killing critical processes like systemd can crash your system.
Find and Kill Linux Processes: Conclusion
Learning how to find and kill processes in Linux is an essential skill. Using tools like ps, top, htop, and kill, you can improve performance, resolve issues, and maintain system stability.
You might also find these guides helpful: