How to Kill a Process in Linux: Terminate Processes Using the Kill and Killall Commands
- HolyHosting

- Oct 30
- 3 min read
When managing a Linux server, you may encounter unresponsive or malfunctioning processes that consume system resources, slow down your work, and negatively impact other running processes. Knowing how to kill a process in Linux is essential for efficient system administration.
This article will guide you through various methods to terminate unresponsive processes in Linux. Whether you are a beginner or an experienced administrator, these methods will help you manage processes effectively in a Linux environment.
What is the kill Process in Linux?
The kill command in Linux terminates a running, unresponsive, or malfunctioning process in a controlled and safe manner.
How to Locate a Process in Linux
Before terminating a process, it’s crucial to identify it correctly. Fortunately, Linux provides several tools for this. The ps and top commands are among the most common.
The ps command shows a snapshot of all running processes, allowing you to find the Process ID (PID) of a specific process. Basic usage:
ps [options]
Common options include:
-a: shows processes for all users.
-u: shows processes for the current user.
-x: includes processes without a terminal.
To narrow the list, combine it with grep. For example, to list all running Java processes:
ps -aux | grep java
The top command provides a dynamic view of all running processes and their resource usage. It requires no additional arguments for basic use.
For more focused searches, pidof and pgrep are useful.
pidof finds a process’s PID by its name:
pidof [options] [process_name]
Example: pidof nginx returns the PID of NGINX processes. Options include:
-c: returns only PIDs in the current root directory.
-o: omits specified PIDs.
-s: returns only one PID, typically the oldest.
pgrep provides flexible searches by name or other properties:
pgrep [options] [pattern]
Example: pgrep -u username finds processes run by a specific user. Options include:
-n: returns the newest matching process.
-o: returns the oldest matching process.
-u: matches processes owned by the specified user.
Kill Command Signals
After identifying the process, send the appropriate signal using kill. Each signal serves a different purpose and affects how the process ends.
List all available signals:
kill -l
Common signals:
SIGTERM (15): default and safest signal for orderly termination.
SIGKILL (9): immediately stops a process without cleanup.
SIGSTOP (19): pauses a process without terminating it.
SIGHUP (1): indicates terminal disconnection, often ending the process.
SIGINT (2): interrupts a process, typically via Ctrl+C.
Specify the signal by name or number. Use SIGTERM for safe shutdowns, SIGKILL only when necessary.
How to Kill a Process in Linux
After understanding signals, here are methods to kill processes on a Linux server. If using a VPS, connect via SSH (e.g., with PuTTY).
Using Holy VPS Browser Terminal:
Log in to Panel → VPS section.
Select your server and access SSH credentials.
Click Browser Terminal to open a terminal in a new tab.
Log in with SSH credentials.
Use kill to terminate a process, e.g.:
kill 63772
Where 63772 is the PID.
Killing a Process Using kill with a PID
To kill a single process:
kill 12345
This sends SIGTERM to PID 12345.
For a forced kill:
kill -9 12345
Killing Multiple Processes
Kill multiple PIDs at once:
kill 12345 67890 13579
Or use a pattern with pgrep:
kill $(pgrep pattern)
Killing a Process Using pkill
pkill kills processes by name or other attributes:
pkill apache
Options:
-u username: kill processes owned by a user.
-t terminal: kill processes attached to a terminal.
-l: list processes with PIDs.
Be careful—pkill apache kills all matching names.
Killing a Process Using killall
killall requires the exact process name:
killall apache
Options include:
-o [time]: kill processes older than specified time.
-y [time]: kill processes newer than specified time.
Example: Kill Chrome processes running over 30 minutes:
killall -o 30m chrome
Conclusion
We hope this guide has been helpful! 🚀 Remember, don’t hesitate to ask questions on the HolyHosting Discord or contact our support team.
Follow us on Twitter @HolyHosting to stay up to date.

Stuffy @ HolyHosting


















