How to Kill an Unresponsive App in Ubuntu?
When an application freezes or becomes unresponsive in Ubuntu, you
can force it to close using several command-line tools. This article
covers the most effective commands for terminating stubborn processes,
including kill, pkill, killall,
and xkill. You will learn how to identify the problematic
application, select the right command based on its Process ID (PID) or
name, and safely force it to shut down.
1. Locate the Unresponsive Process
Before you can terminate an application, you often need to find its name or Process ID (PID). Ubuntu provides a couple of quick terminal tools for this:
ps aux: Lists all running processes. You can pipe this intogrepto find a specific app (e.g.,ps aux | grep firefox).- **
toporhtop**: Displays a real-time, interactive list of active processes, making it easy to spot which application is freezing or consuming too much CPU.
2. The Standard kill
Command
The standard kill command is used when you know the
specific Process ID (PID) of the unresponsive application. By default,
it sends a polite termination signal, but it can be escalated if the app
refuses to close.
- Normal Termination (SIGTERM):
kill <PID>This asks the application to close down cleanly, allowing it to save data if possible. - Forceful Termination (SIGKILL):
kill -9 <PID>If the application is completely frozen and ignores the standard command, adding-9forces the Linux kernel to shut down the process immediately.
3. Kill by Name:
pkill and killall
If you do not want to hunt down a specific PID number, you can target the application directly by its process name.
Using pkill
The pkill command looks for processes that match the
name you type. It is highly flexible because it works even if you only
type a partial name.
- Command:
pkill firefox - Force Close:
pkill -9 firefox
Using killall
The killall command is more precise. It kills all
instances of a process, but it requires the exact, full name of the
application.
- Command:
killall chrome - Force Close:
killall -9 chrome
4. The Graphical Shortcut:
xkill
If you prefer a quick point-and-click solution without looking up
names or numbers, xkill is a powerful utility for graphical
applications.
- Open your terminal and type:
xkill - Your mouse cursor will transform into a crosshair or an “X” icon.
- Click directly on the frozen application window. The system will instantly terminate that specific GUI process.