How to Kill a Process in Ubuntu: Complete Guide

Learn how to identify and kill processes in Ubuntu using command-line and GUI tools. Step-by-step instructions, safety tips, and troubleshooting are included.

Updated: 06 Oct, 25 by Susith Nonis 10 Min

List of content you will read in this article:

Effectively managing processes is a valuable skill for any Ubuntu user. It would be useful to know the technical methods for kill process Ubuntu to handle frozen applications, optimize systems, or troubleshoot any issues. This tutorial walks you step-by-step through the methods and commands required to perform all sorts of terminations- from a polite "please exit" to a harsh-mannered "please exit now."

We will cover command-line and graphical tools, with explanations for all signals that can be sent to control processes, and quite interesting tips that should prevent you from crashing your system. This is especially great knowledge for developers and administrators whose actions on an Ubuntu VPS Hosting are mostly command-line oriented.

Kill a Process in Ubuntu

Before terminating a process, it's helpful to understand what it is. A process is an active instance of a program. The system assigns each process a unique Process ID (PID) to manage it. Processes can exist in several states, but the most common are:

  • Running: The process is currently executing on the CPU.
  • Sleeping: The process is waiting for a resource or an event. Most processes are in this state.
  • Stopped: The process has been paused (e.g., by the SIGSTOP signal) and can be resumed.
  • Zombie: The process has completed its execution but still has an entry in the process table.

Understanding these states can help you diagnose why an application is misbehaving.

For developers and administrators working mostly in command-line environments, using an Ubuntu VPS Hosting can provide a reliable and scalable setup for managing processes efficiently.

The terminal provides several powerful commands to kill process Ubuntu. Let's explore the most important ones.

🎯 Using the kill Command

The kill command is the most direct way to terminate a process when you know its PID. It works by sending a signal to the specified process. The default signal is SIGTERM, which requests a graceful shutdown.

kill comand

  1. First, find the PID using ps aux | grep <process_name> or pgrep <process_name>.
  2. Then, use the kill command with the PID. For example, to gracefully terminate a process with PID 12345:

kill 12345

  1. If the process is stuck and won't close, you can force it to terminate by sending the SIGKILL signal (-9):

kill -9 12345

To learn more about the various signals and options, you can dive deeper into the Linux Kill Process with our detailed guide.

🏹 Using pkill and killall Commands

These commands are extremely useful when you want to kill a process by name in Ubuntu instead of by PID.

  • pkill: This command kills processes based on their name or other attributes. It's flexible because it can match partial names.

# Gracefully kill all processes with 'firefox' in their name

pkill firefox

pkill command

  • killall: This command is stricter than pkill. It kills all processes that exactly match the provided name.

# Forcefully kill all processes named exactly 'gimp'

killall -9 gimp

kill all command

This distinction makes pkill more convenient for general use, while killall offers greater precision to avoid accidentally terminating unintended processes.

For a more visual and interactive approach in the terminal, you can use process management tools.

📈 top and htop

top is a classic, built-in utility that provides a real-time view of your system's processes. htop is a more modern, user-friendly alternative with a colorized interface, easier navigation, and more intuitive controls.

If htop isn't installed, you can add it with sudo apt install htop.

To use htop to kill a process:

  1. Launch it by typing htop in the terminal.
  2. Use the arrow keys to scroll and highlight the unresponsive process.
  3. Press the k key to send a signal.
  4. Choose the signal from the left-hand menu (e.g., 15 SIGTERM or 9 SIGKILL) and press Enter.

These tools are excellent for getting a complete overview of your system. For more ways to view running tasks, explore our resource on the Linux Process List.

🖼️ Ubuntu System Monitor (GUI)

For users who prefer a graphical interface, Ubuntu provides the System Monitor.

  1. Open the "Show Applications" menu and search for "System Monitor".
  2. Navigate to the Processes tab.
  3. Find the process you want to terminate. You can click on column headers to sort by CPU, Memory, or Name.
  4. Right-click the process and select End (for a graceful SIGTERM) or Kill (for a forceful SIGKILL).
  5. A confirmation dialog will appear. Confirm your choice to terminate the process.

This graphical approach is often the quickest and most intuitive method for desktop users to handle unresponsive applications.

When you use a kill command, you're sending a signal. Understanding the difference between the most common signals is key to managing processes effectively.

😈 SIGTERM vs SIGKILL and Others

When you want to control a process, you send it a message called a signal. These signals tell the process what to do, from politely asking it to close to forcefully shutting it down without warning. Using the correct signal is key to managing your system safely and effectively.

  • SIGTERM (Signal 15): The Graceful Shutdown. This is the default and safest signal. It acts as a polite request, allowing the program to perform cleanup tasks like saving data and closing files before it exits.
  • SIGKILL (Signal 9): The Forceful Termination. This is the ultimate last resort. It's a non-ignorable command that forces the process to terminate immediately, which can sometimes lead to data corruption, as there is no chance for cleanup.
  • SIGSTOP (Signal 19): The Pause Button. This signal doesn't end a process but temporarily freezes it. The process remains loaded in memory and can be resumed exactly where it left off with a SIGCONT (continue) signal.

Always start with the gentle SIGTERM to allow for a clean exit and prevent data loss. You should only escalate to the forceful SIGKILL when a process is completely unresponsive.

Even with the right commands, sometimes killing a process in Ubuntu doesn’t go as planned. Errors like permission denied, processes that restart automatically, or tasks that stubbornly refuse to die are all common issues. Understanding the cause behind each situation helps you apply the right fix without damaging your system stability.

Issue

Cause

Solution

Permission Denied

The process belongs to another user or root, so you lack privileges.

Use sudo kill -9 <PID> to run the command with administrative rights.

Process Restarts Automatically

The process is controlled by a service manager such as systemd.

Stop the service instead: sudo systemctl stop <service-name>.

Process Won’t Die

The process is in uninterruptible sleep, often waiting for disk or network I/O.

Use kill -9 <PID>. If that fails, wait for the I/O to finish or reboot if necessary.

These troubleshooting steps cover the most frequent obstacles you’ll face when terminating processes. By carefully diagnosing the root cause, you can resolve issues safely without destabilizing your Ubuntu system.

Advanced users often prefer automating repetitive system tasks instead of handling them manually each time. Process management can be scripted so that resource-hungry or frozen applications are automatically detected and terminated.

#!/bin/bash 

PROCESS_NAME="my_app"

PID=$(pgrep $PROCESS_NAME)

if [ -n "$PID" ]; then

  echo "Killing $PROCESS_NAME with PID $PID"

  kill $PID

fi

You can also extend this script to restart the application after termination or run it periodically using cron jobs. With these methods, your Ubuntu system can self-manage troublesome processes without constant manual intervention.

Terminating processes is powerful, but it must be done carefully to avoid damaging your system. A single wrong command can crash your desktop environment, cause data loss, or even force a hard reboot. That’s why it’s important to follow a set of best practices before executing kill commands.

  • Use SIGTERM first: Always start with a graceful termination before resorting to SIGKILL (-9).
  • Verify the PID: Double-check the process ID with ps, pgrep, or htop to ensure you’re targeting the correct process.
  • Research unknown processes: If you don’t recognize a process, look it up instead of killing it blindly.
  • Avoid critical system tasks: Do not terminate essential processes like systemd (PID 1), Xorg, gnome-shell, or kernel threads (names in brackets such as [kthreadd]).

By applying these precautions, you minimize the risk of destabilizing your system. Careful process management not only keeps your environment secure but also ensures applications close cleanly. In the long run, these habits save time and prevent costly troubleshooting later.

Having sound knowledge of managing and terminating processes in Ubuntu is key to keeping the system stable, resolving program freezing, and boosting productivity. The core things to keep in mind include the signals behind termination, based on caution, and best practices when using the command line and tools such as kill, pkill, htop, or the graphical way through System Monitor

The end goal is to have a couple of tricks for getting rid of frozen processes using automation scripts and other safety measures without endangering one's ongoing work or crashing the machine.

 You can use the command kill , pkill , or the graphical System Monitor. For example, pkill firefox.

 kill terminates a process based on its Process ID (PID), while pkill terminates processes based on their name.

 Use the SIGKILL signal with the -9 flag, for example: kill -9 or pkill -9 .

 Yes, use the pkill or killall command with the process name. For example: pkill gedit.

 Killing a critical system process can cause your desktop session to crash, force your system to become unresponsive, or even require a hard reboot. 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.

user monovm

Orie Kilback

2024, Nov, 24

Great explanation on using the 'kill' command in Ubuntu! It's essential for anyone looking to manage processes effectively. I like how you outlined the differences between stopping, terminating, and forcefully killing processes, including the importance of using the correct signals. The step-by-step guides for both graphical and terminal methods are clear and easy to follow. This will definitely help users optimize their system's performance more efficiently!

user monovm

Frankie Toy

2024, Dec, 24

Great post! This guide is an excellent resource for anyone navigating Ubuntu and needing to understand process management. You've broken down the commands clearly and highlighted the importance of using 'kill' responsibly. The distinctions between stopping, ending, and killing processes are particularly helpful for understanding the impact on system stability. Keep up the fantastic work in simplifying complex topics for Linux users!

user monovm

Mathias Huels

2025, Feb, 25

Great post! Understanding and mastering the 'kill' command is indeed a vital skill for any Ubuntu user who wants to efficiently manage their system processes. Your guide does an excellent job in breaking down the differences between stopping, ending, and killing processes, which helps in making informed decisions. It's practical information like this that empowers users to enhance their system management capabilities. Thanks for sharing such a comprehensive resource!

user monovm

Prof. Angelina Little PhD

2025, Apr, 25

This guide on using the 'kill' command in Ubuntu is incredibly insightful and essential for any user looking to gain more control over their system's processes. The distinction between stopping, ending, and killing processes is crucial, and you've explained it well, highlighting both graphical and terminal methods. It's a great resource for anyone keen to optimize or troubleshoot their system effectively. Thanks for breaking it down so clearly!