How to Kill a Process in Linux: A Complete, Practical Guide

Updated on December 19, 2025, by Xcitium

How to Kill a Process in Linux: A Complete, Practical Guide
  • Ever had a Linux application freeze, spike CPU usage, or refuse to close? Whether you’re troubleshooting a misbehaving service, stopping a runaway script, or responding to a security incident, knowing how to kill a process in Linux is a fundamental skill.

    Linux gives you precise control over processes—but with that power comes responsibility. In this guide, you’ll learn how to kill a process in Linux safely and effectively, using the right commands, signals, and tools. We’ll cover beginner-friendly methods and advanced techniques used by sysadmins and security teams alike.

    What Does “Kill a Process in Linux” Mean?

    In Linux, to “kill” a process means to send a signal to a running program. Contrary to the name, killing doesn’t always mean immediate termination. Signals can request a graceful shutdown, pause execution, reload configuration, or force termination when needed.

    Understanding how to kill a process in Linux starts with understanding signals and process IDs (PIDs).

    Why You Might Need to Kill a Process in Linux

    There are many legitimate reasons to terminate a process:

    • An application is frozen or unresponsive

    • A process is consuming excessive CPU or memory

    • A service failed to shut down cleanly

    • A script is stuck in an infinite loop

    • Malware or suspicious activity is detected

    • You need to free locked resources

    For IT managers and security teams, knowing how to kill a process in Linux can prevent outages, reduce risk, and restore system stability quickly.

    Linux Processes and PIDs Explained

    Every running program in Linux is a process, and each process has a unique Process ID (PID).

    You can view processes using commands like:

    • ps

    • top

    • htop

    Before you kill a process, you usually need its PID—unless you’re killing it by name.

    Method 1: How to Kill a Process in Linux Using kill

    The kill command is the most common way to terminate a process.

    Basic Syntax

    kill [signal] PID

    Example

    kill 1234

    This sends the default signal (SIGTERM) to process 1234, asking it to terminate gracefully.

    Common Signals You Should Know

    • SIGTERM (15) – Graceful shutdown (default)

    • SIGKILL (9) – Force kill (cannot be ignored)

    • SIGINT (2) – Interrupt (similar to Ctrl+C)

    • SIGHUP (1) – Reload configuration

    Best practice: always try SIGTERM first before using SIGKILL.

    Method 2: How to Kill a Process in Linux by Name Using pkill

    If you don’t know the PID, pkill lets you terminate processes by name.

    Example

    pkill firefox

    This kills all processes named firefox.

    More Precise Matching

    pkill -f python_script.py

    The -f flag matches against the full command line, not just the process name.

    ⚠️ Be careful—pkill can terminate multiple processes at once.

    Method 3: How to Kill a Process in Linux Using killall

    killall sends signals to all processes matching a name.

    Example

    killall nginx

    This stops all running nginx processes.

    Unlike pkill, killall matches exact process names, which can be safer in some cases.

    Method 4: How to Kill a Process in Linux from top

    top provides a real-time view of system activity and lets you kill processes interactively.

    Steps

    1. Run:

      top
    2. Press k

    3. Enter the PID

    4. Choose a signal (default is 15)

    This is useful when diagnosing performance issues visually.

    Method 5: How to Kill a Process in Linux Using htop

    htop is a more user-friendly alternative to top.

    Why Use htop

    • Color-coded interface

    • Easier navigation

    • Process tree view

    Steps

    1. Launch:

      htop
    2. Select the process

    3. Press F9

    4. Choose the signal

    5. Confirm

    If you manage Linux systems regularly, htop is highly recommended.

    Method 6: How to Kill a Hung Terminal Process

    If a command locks up your terminal:

    Use Ctrl+C

    Sends SIGINT to the foreground process.

    If That Fails

    • Open a new terminal

    • Find the PID:

      ps aux | grep command_name
    • Kill it:

      kill PID

    This is a common scenario when learning how to kill a process in Linux.

    Force Killing a Process: When and Why

    Sometimes, a process ignores SIGTERM. In these cases, use SIGKILL.

    Example

    kill -9 PID

    Important Warning

    SIGKILL:

    • Cannot be ignored

    • Prevents cleanup

    • May cause data loss

    Only use it when absolutely necessary.

    How to Kill Multiple Processes in Linux

    You can kill multiple PIDs at once:

    kill 1234 5678 9012

    Or by pattern:

    pkill -u username

    This kills all processes owned by a specific user—useful during account cleanup or incident response.

    How to Kill Zombie Processes in Linux

    Zombie processes are already dead but still listed because the parent process hasn’t collected their exit status.

    Key Point

    You cannot directly kill a zombie process.

    Solution

    • Identify the parent PID (PPID)

    • Restart or kill the parent process

    ps -ef | grep Z

    Understanding this distinction is essential when learning how to kill a process in Linux.

    How to Kill a Process in Linux Safely (Best Practices)

    Follow these guidelines to avoid system damage:

    • Always identify the process first

    • Prefer graceful termination (SIGTERM)

    • Avoid killing system-critical processes

    • Use sudo only when required

    • Document actions in production environments

    For servers, reckless process termination can cause downtime or data corruption.

    Security Use Case: Killing Malicious Processes

    In cybersecurity scenarios, knowing how to kill a process in Linux is critical.

    Signs of Malicious Processes

    • Unusual CPU or network usage

    • Random process names

    • Processes running from /tmp or hidden directories

    Response Steps

    1. Isolate the system (if possible)

    2. Identify suspicious processes

    3. Kill the process

    4. Investigate persistence mechanisms

    Endpoint containment solutions can automate this process and prevent reinfection.

    Automating Process Control with Scripts

    Linux admins often automate process management.

    Example Script

    #!/bin/bash
    PID=$(pgrep myapp)
    if [ -n "$PID" ]; then
    kill $PID
    fi

    Automation reduces response time and human error.

    How Killing Processes Fits into System Administration

    Knowing how to kill a process in Linux is a foundational sysadmin skill.

    It supports:

    • Troubleshooting

    • Performance tuning

    • Incident response

    • Maintenance automation

    For IT managers, it ensures faster recovery and more stable systems.

    Common Mistakes When Killing Linux Processes

    Avoid these pitfalls:

    ❌ Using kill -9 by default
    ❌ Killing unknown PIDs
    ❌ Terminating system daemons blindly
    ❌ Forgetting to verify process ownership
    ❌ Not checking logs after termination

    Smart process control protects uptime and data integrity.

    How to Check If a Process Was Killed Successfully

    After killing a process, verify:

    ps -p PID

    If no output appears, the process is gone.

    You can also check logs:

    journalctl -xe

    Frequently Asked Questions (FAQ)

    1. What is the safest way to kill a process in Linux?

    Using kill PID (SIGTERM) is the safest method because it allows graceful shutdown.

    2. What’s the difference between kill and pkill?

    kill targets a specific PID, while pkill targets processes by name or pattern.

    3. Why won’t a process die even after kill?

    It may be stuck in kernel mode or require SIGKILL.

    4. Can killing a process crash Linux?

    Killing critical system processes can destabilize the system, especially when using SIGKILL.

    5. Do I need sudo to kill a process?

    Only if the process belongs to another user or the system.

    Final Thoughts

    Mastering how to kill a process in Linux gives you precise control over your systems. From everyday troubleshooting to security incident response, the ability to identify and terminate processes safely is essential for Linux users, sysadmins, and security teams.

    When combined with modern endpoint security and containment, process control becomes a powerful defense tool—not just a maintenance task.

    👉 Want stronger protection and automated threat containment for Linux endpoints?
    Request a demo today:
    https://www.xcitium.com/request-demo/

See our Unified Zero Trust (UZT) Platform in Action
Request a Demo

Protect Against Zero-Day Threats
from Endpoints to Cloud Workloads

Product of the Year 2025
Newsletter Signup

Please give us a star rating based on your experience.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Expand Your Knowledge

By clicking “Accept All" button, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Disclosure

Manage Consent Preferences

When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.

These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.