How to Use the kill Command to Force Quit Unresponsive Programs in Ubuntu

Even on a highly stable operating system like Ubuntu Linux, software can occasionally crash. A web browser might lock up entirely, a script you are running might enter an infinite loop, or a background service might hang, refusing to shut down normally. In a graphical environment, you might try clicking the “X” repeatedly, but if the system is completely unresponsive, you must drop down to the terminal to resolve the issue.

Linux manages every running program as a “process,” and every process is assigned a unique Process ID (PID). By identifying the PID of the frozen application, you can send a specific signal directly to the Linux kernel, ordering it to instantly terminate the program regardless of its current state.

This guide explains how to find process IDs and use the kill command to force quit unresponsive applications in Ubuntu.

Step 1: Find the Process ID (PID)

Before you can kill a program, you need to know its exact ID number. There are several ways to find this.

Method A: Using the pidof Command
If you know the exact name of the software that crashed (for example, Firefox), you can ask the system for its PID directly:

pidof firefox

This will output a number (or several numbers, if the program uses multiple threads), such as 4821.

Method B: Using the top Command
If the system is acting sluggish and you are not sure which program is causing the issue, you can view a live list of all running processes sorted by resource usage:

top

Look at the very first column on the left labeled PID. Find the misbehaving command in the list, note its PID number, and press the Q key to exit the top interface.

Step 2: Terminate the Process

Once you have the PID (let’s assume it is 4821 for this example), you can use the kill command. By default, typing kill sends a “SIGTERM” (Signal 15) request. This politely asks the program to save its data, close its files, and shut down cleanly.

kill 4821

Wait a few seconds. If the program closes, you are finished. However, if the program is completely frozen, it will likely ignore this polite request.

Step 3: Force Quit (The Nuclear Option)

If the standard kill command fails, you must send a “SIGKILL” (Signal 9). This command bypasses the program entirely and orders the Linux kernel to instantly wipe the process from memory. The program cannot ignore this command, but any unsaved data within that application will be permanently lost.

To force quit the process, add the -9 flag to the command:

kill -9 4821

Alternative: The Graphical killall Command

If you are dealing with a program that spawns dozens of smaller background processes (like Google Chrome), finding and killing every single PID manually is tedious. Instead, you can use the killall command followed by the name of the application to terminate all associated processes simultaneously:

killall -9 chrome

Use the -9 flag with caution, but rest assured that it will immediately free up your system resources and resolve the freeze.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.