When managing a Linux system, you may encounter a situation where a process becomes unresponsive or needs to be manually stopped. Knowing how to terminate a process in Linux is a key skill for both system administrators and developers.
A process is an instance of a running program. Every process in Linux has a unique PID (Process ID), which is used to monitor or control it.
You may want to terminate a process if:
It’s consuming too many resources
It’s stuck or frozen
You need to restart the service or application
You want to manually stop a background script or daemon
Before you terminate anything, you need to find out the PID of the process. Here are a few ways:
Run top and find the PID in the leftmost column.
htop (if installed) offers an interactive, user-friendly interface.
This returns the PID(s) directly, if the process name is known.
Send a termination signal (default is SIGTERM – signal 15):
If the process won’t stop with a normal kill signal, use SIGKILL (signal 9):
This forces the process to stop immediately.
To terminate all processes with a specific name:
You can also add -9 to force it:
pkill allows matching process names with regex-style patterns:
Or forcefully:
If you’re running a Linux desktop and need to kill a graphical application:
Run:
Click on the window you want to terminate.
Note: xkill must be installed and X server must be running.
Signal | Number | Description |
---|---|---|
SIGTERM | 15 | Graceful stop |
SIGKILL | 9 | Forceful, immediate kill |
SIGHUP | 1 | Hang up / restart daemon |
SIGINT | 2 | Interrupt (like Ctrl+C) |
Always try graceful termination (kill) before using forceful methods like kill -9.
Make sure you double-check the PID so you don’t kill an important system process.
For critical services, it’s better to use system management tools like systemctl:
If you frequently manage processes, install htop:
This tool lets you interactively kill processes by selecting them and pressing F9.
By mastering these tools, you gain more control over your Linux environment and ensure that stuck or rogue processes don’t compromise system performance.