Unlike standard desktop operating systems where you can easily press Ctrl+Alt+Delete to launch a Task Manager, managing a completely frozen application on a Linux server or headless environment can be slightly more challenging. When an application locks up, consuming all your CPU resources and refusing to close, you need to intervene directly via the command line.
Fortunately, the Linux terminal provides incredibly powerful tools for process management. By learning a few simple commands, you can instantly identify the misbehaving application and forcefully terminate it.
In this guide, we will walk you through the professional workflow for finding the Process ID (PID) of a frozen application and killing it safely using the terminal.
Step 1: Locate the Frozen Process ID (PID)
Every application and background service running on your Linux machine is assigned a unique number known as a Process ID (PID). Before you can kill a program, you must first discover its PID. There are two primary commands for this: top and ps.
Using the ‘top’ Command (Interactive)
If your entire system is running slowly, you likely want to see which processes are consuming the most CPU or memory.
- Open your terminal.
- Type
topand press Enter. - You will see a live, constantly updating list of your system’s processes. Look at the column on the far left labelled PID. Find the name of the frozen application in the right-most column (COMMAND) and note its corresponding PID.
- Press the Q key to exit the top interface.
Using the ‘ps’ Command (Direct Search)
If you already know the name of the application that is frozen (for example, Firefox or an Apache web server), the ps command combined with grep is much faster.
- Type
ps aux | grep firefox(replacing “firefox” with the name of your application) and press Enter. - The terminal will output a few lines of text. The second column in this output is the PID. Note this number down carefully.
Step 2: Terminate the Process Gently (SIGTERM)
Once you have the PID, it is time to stop the application. The best practice in Linux administration is to try and close the application gently first. This allows the program to save its data and shut down correctly.
Use the standard kill command followed by the PID. For example, if your PID is 4512, you would type:
kill 4512
Press Enter. Wait a few seconds and then run your ps aux command again to see if the process has disappeared. If it has, congratulations—you have successfully managed the frozen application.
Step 3: Force Kill a Stubborn Process (SIGKILL)
Sometimes, a process is so completely locked up that it ignores your gentle request to shut down. In this scenario, you must force the Linux kernel to terminate the application immediately, bypassing the application’s own shutdown procedures.
To do this, you pass the -9 flag to the kill command. This sends a SIGKILL signal. Using our previous example PID of 4512, you would type:
kill -9 4512
Press Enter. The operating system will instantly destroy the process and free up its resources. Note that any unsaved work within that application will be permanently lost.
Alternative Method: Kill by Name (killall)
If you are dealing with an application that has spawned dozens of child processes (like Google Chrome), finding and killing every single PID manually is incredibly tedious. Instead, you can kill all processes associated with a specific name simultaneously.
To do this, use the killall command:
killall chrome
This command will locate every running instance of Chrome and send a termination signal to all of them at once. It is a highly efficient way to clear out massive application crashes.
By keeping these commands in your toolkit, you will be able to manage even the most unstable Linux systems with confidence and professionalism.