How to Kill Processes in Ubuntu 22.04?

While Working with Multiple Programs in Ubuntu, the system resources sometimes get limited. Either you run out of RAM Memory, or you run out of CPU Memory. Also, closing an Application or a Process on your Ubuntu System does not usually Kill or Terminate all the processes of the Application. The Application still runs in the Background consuming system resources which eventually increases the memory usage leading to a slower system. Thus, it is necessary to kill all the running processes of your Ubuntu System to run efficiently.

Sponsored

This article explains the killing of processes in various methods.

How to Kill Processes in Ubuntu 22.04?

Ubuntu allows the User to Kill or terminate a specific process or multiple processes either through the GUI or through the Terminal. To Kill a Process in Ubuntu, the methods used are:

  • Killing a Process through GUI by using the System Monitor Application.
  • Killing a Process using the “kill” Command.
  • Killing a Process using the “killall” Command.
  • Killing a Process using the “pkill” Command.

All the methods are deliberated in detail in the sections below.

Method 1: Killing a Process in Ubuntu through GUI

The Ubuntu GUI offers the System Monitor pre-installed application which lists all the running processes on your Ubuntu System. To start the System Monitor application, navigate to the Application Menu from your Ubunut Home Screen by clicking on the Application menu Icon:

In the Application Menu, type “System Monitor” in the top search bar. The System Monitor Application will filter out. Click on the Application Icon to start the System Monitor Application:

In the System Monitor Application, you will see the Resources Tab opened. In the Resources tab, you will see the CPU usage, the network usage, and the Memory usage:

To view the running Processes on your Ubuntu System, click on the Processes Tab available next to the Resources Tab:

After you click on the Processes Tab, the Processes Menu will appear where you will see all the Processes currently running are listed. The Listed Processes will also contain the Process ID, the process user, and the Memory and CPU usage utilized by the processes:

To kill a process from the System Monitor, click on any process among the list of processes. In our case, we will click on the “firefox” application process:

Once you click on a process, you will notice a “End Process” Button at the bottom of the System Monitor Window:

Click on the “End Process” button and a new window will pop up asking for the confirmation to end the process. Click on the “End Process” option to end the selected process:

Once the process ends, you can verify through the Processes List again as the Application will not be listed again:

Apart from Ending a Process, you can also check the details of a Process. In our case, we will check the “baobab” Application Details:

Once the application process is selected, click on the “Settings” gear icon at the bottom right of the System Monitor Window:

After you click on the Settings Icon, the details of the Application will open in a new window where you can see the Status of the Application, The Memory Usage, the Process ID, and many more:

Method 2: Killing a Process in Ubuntu through CLI

The Terminal in Ubuntu offers multiple commands to kill a running process. Killing a process from the Terminal is also much more useful, as, with the Terminal Commands, you can kill the specific process ID of an Application and you can also forcefully kill a Process.

List Running Processes

Before Killing a Process in Ubuntu through the Terminal, you have to list the running Processes in your Ubuntu system. To list the running processes, use the “ps aux” command:

ps aux

The list of processes currently running will be listed in Ascending Order in the Terminal. Note that the Processes Listed will be in Ascending Order According to their Process IDs:

With the “ps aux” command, you can also list the Running Processes of a specific Application as well. In our case, to list the running processes of the “firefox” application in the Terminal, the “ps aux” command will be used along with the “grep” command to filter the list:

ps aux | grep firefox

All the Running Processes along with the process IDs of the Firefox Application will appear in the Terminal:

Apart from the “ps aux” command, the “top” command is also useful to list the running processes in your Terminal. The advantage of the “top” command over the “ps aux” is that with the “top” command, the Terminal Displays the Processes in a way similar to the System Monitor. To display the processes, simply use the “top” command in the Terminal:

top

The Terminal will display the list of running processes where you can also see the Memory Usage of the Applications:

Approach 1: Using the “kill” Command

The “kill” is a useful command for terminating or killing running processes manually. The “kill” command simply takes the Process ID of a running process and Terminates it. The syntax of the “kill” command is:

kill <options> <processID>

Before killing a process of an Application, run the “pidof” command to list the processes of a specific application:

pidof <application>

In our case, we will list the processes of the “firefox” application. To list all the processes, use the “pidof” command:

pidof firefox

All the running processes of the “firefox” application will be listed in the Terminal:

You can now kill a process according to your own choice. Either you can kill only one process, or you can kill multiple processes with the syntax:

See also  How to Use the Gpg Command on Ubuntu
kill <option> <processID-1> <processID-2><processID-N>

If you want to Forcefully Kill a Process, Use the “SIGKILL” command along with the “kill” command. Instead of the “SIGKILL” command, the signal “-9” can be used as an option with the “kill” command. Note that the SIGKILL and the signal “-9” are the same. To forcefully kill a process, use the “-9” option with the “kill” command along with the process ID:

Sponsored
kill -9 <processID>

In our case, we will forcefully kill the “3762” Process ID of the Firefox Application. To forcefully kill the Process ID 3762, the “kill” command along with the “-9” signal will be:

kill -9 3762

The cursor moving to the next line indicates that the process ID was terminated or killed:

You can verify the Killed Process ID with the “pidof” command. In our case, to verify the killed process of “firefox”, the “pidof” command will be used again:

pidof firefox

As you can see, the Process ID 3762 is not listed again indicating that the process was Killed:

If you are not comfortable with using the “-9” signal, you can use the “SIGKILL” Command along with the “kill” command as well, having the syntax:

kill -s SIGKILL <processID>

In our case, to forcefully kill the Process ID 3759 of the Firefox Application, the SIGKILL Command will be:

kill -s SIGKILL 3759

The cursor moving to the next line indicates the process was killed or terminated successfully:

To verify the killed process ID, use the “pidof” command again with the application name, in our case, “firefox”:

pidof firefox

As you can see in the Terminal, the Process ID 3759 was Terminated or Killed:

The SIGKILL Command can also be used along with the “kill” command to terminal or kill multiple processes at a time with the syntax:

kill -s SIGKILL <processID-1> <processID-2><processID-N>

In our case, to kill multiple processes of the Firefox Application running on our Ubuntu System, the “kill” command along with the SIGKILL command will be:

kill -s SIGKILL 3599 3480 3458 3296

This will forcefully kill the multiple processes:

To verify if the processes were killed, use the “pidof” command again to list the running processes of the “firefox” application:

pidof firefox

As nothing is returned in the Terminal, it ensures that all the processes of the Firefox Application were forcefully killed with the SIGKILL command:

Approach 2: Using the “killall” Command

Instead of Terminating or Killing all the processes by writing the Process ID one by one with the “kill” command, the “killall” command can be used. The “killall” command will kill all the running processes of the Running Application or Process. To kill or terminate all the processes of a Process or an Application, the “killall” command will have the syntax:

killall <processName>

In our case, to list all the running processes of the Firefox Application, the “pidof” command will be:

See also  How to Install Plex in Ubuntu 22.04
pidof firefox

All the Running Firefox Processes will be displayed in the Terminal:

Now, to kill all the running processes of the Firefox Application, the “killall” command will be:

killall firefox

The cursor will move to the next line once the “killall” command kills the running processes of Firefox:

To verify if the processes were killed with the “killall” command, use the “pidof” command again which will list the running processes of Firefox:

pidof firefox

As no running processes are displayed in the Terminal, it ensures that all the processes were killed:

You can also forcefully kill all the processes using the “SIGKILL” command along with the “killall” command having the syntax:

killall -s SIGKILL <processName>

In our case, to kill all the processes of the Firefox Application, the SIGKILL Command will be:

killall -s SIGKILL firefox

This will forcefully kill all the running processes of the Firefox Application:

Approach 3: Using the “pkill” Command

The “pkill” command is also a useful command to kill or terminate a running process on Ubuntu through the Terminal. The “pkill” command will kill all the running processes of an Application. To use the “pkill” command, use the Process or the Application name along with the “pkill” command:

pkill <processName>

In our case, to kill all the running Processes of the “firefox” application, the “pkill” command will be:

pkill firefox

The cursor moves to the next line indicating the processes were killed or terminated:

To verify, use the “pidof” command again. In our case, no processes are returned, ensuring that all the running processes of Firefox were Killed:

You can also Forcefully Kill a Process using the “SIGKILL” command along with the “pkill” command having the syntax:

pkill -SIGKILL <processName>

In our case, to kill or terminate all the running processes of the Application “firefox”, the “pkill” command will be:

pkill -SIGKILL firefox

This will terminate all the running processes of the Firefox Application forcefully:

Conclusion

Killing or Terminating a Process or processes of a specific Application in Ubuntu increases the Efficiency and speed of the overall system. Killing a Process frees up Memory or CPU resources. To kill a process in Ubuntu, the “System Monitor” can be used through the GUI. Also, the “kill” command, the “killall” command, and the “pkill” command are useful when terminating or killing specific or all processes from the Terminal in Ubuntu.

Leave a Comment

Only people in my network can comment.