When an application freezes, stops responding, or starts consuming too much CPU on your Ubuntu Linux system, you cannot always rely on closing it politely with the “X” button in the graphical interface. In these situations, you need to forcefully terminate the program using the command line. The kill command is the standard Linux tool for sending termination signals to misbehaving processes. By finding the program’s unique ID and passing it to the kill command, you can regain control of your system.
Step 1: Find the Process ID (PID)
Before you can kill a process, you must know its Process ID (PID). The PID is a unique number assigned by the Linux kernel to every running program. You cannot just type “kill firefox”; the command specifically requires the PID number.
To find the PID, use the ps (process status) command combined with grep to search for the specific name of the frozen application.
- Open your terminal (Ctrl + Alt + T).
- Type the following command, replacing “firefox” with the name of your unresponsive app:
ps aux | grep firefox - Press Enter.
- You will see a list of results. Look closely at the columns. The second column from the left contains the PID numbers (e.g., 4012, 4055).
Step 2: Use the kill Command
Once you have identified the correct PID, you can send a signal to terminate it. The standard kill command sends a polite “SIGTERM” (Signal 15) request, asking the program to save its data and shut down gracefully.
- Type
killfollowed by a space, and then the PID number you found in Step 1. For example:kill 4012 - Press Enter.
- If the command is successful, the terminal will simply return to a new prompt without any confirmation message. The application window should close.
Step 3: Force Kill a Stubborn Process (SIGKILL)
If the application is completely frozen and ignores the polite kill command, you must use the “SIGKILL” signal. This is a forceful termination; the program is immediately destroyed by the operating system, and any unsaved data will be lost.
You apply a force kill using the -9 flag.
- Type the command using the
-9flag followed by the PID. For example:kill -9 4012 - Press Enter. The process will be terminated instantly.
Alternative: Use the killall Command
If you have multiple instances of the same program running (like five different Google Chrome background processes) and you want to kill all of them at once without looking up every single PID, you can use the killall command.
Unlike kill, killall uses the actual name of the program.
killall chrome
This will terminate every process associated with the name “chrome”. Be careful with this command, as it is a broad brush and will close everything matching that name simultaneously.