top of page

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

  • Writer: HolyHosting
    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:

  1. Log in to Panel → VPS section.

  2. Select your server and access SSH credentials.

  3. Click Browser Terminal to open a terminal in a new tab.

  4. Log in with SSH credentials.

  5. 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.

ree

Stuffy @ HolyHosting

 
 

Related Posts

See All
How to Fix the "Mismatched Mod Channels" Error

Hello, HolyHosting players! 🌟We know that playing on modded servers is super fun, but it can also be a headache 🧠 when your mods don’t match between your game and the server. 😩 Here’s how to fix th

 
 

CREATE YOUR SERVER

READY TO GET STARTED?

Start today and we’ll offer you a 25% discount on your first bill with our new customer promotion!

Etiqueta.png
View active promotions and coupons
holyhosting logo

Powerful servers at affordable prices.

HolyHosting

Copyright © 2025 HOLY SERVERS LLC, operating under the name HolyHosting.

REG. NO.: 001599788. This business entity is officially registered at 30 N Gould St, Suite N, Sheridan, WY 82801, Wyoming, US.

  • X
  • Instagram
  • Facebook
  • Discordia
  • YouTube
  • Tik Tok

POPULAR

US

SUPPORT

Minecraft
Minecraft Dedicated Hosting
Discord Bot Hosting
Other Games Hosting
Voice Server Hosting
MC Servers Panel
Games Servers Panel

About Us
Client Area
Branding
Payment Methods
Hardware by Location
Terms and Conditions
Privacy Policies
Refund Policies

Create a Ticket
Knowledge Base
Discord
Network Status
Request Affiliation

dmca

Copyright © 2025 HOLY SERVERS LLC, operating under the registered name HolyHosting. All rights reserved.

The payment process may be handled by Tebex Limited, acting as the registered merchant and being responsible for product fulfillment and handling billing inquiries.

bottom of page