How to kill a process on Ubuntu

This tutorial will teach you how to kill a process on the Ubuntu operating system.

Ubuntu kill process

If you have ever had a process on Ubuntu that wouldn’t close, no matter what you did, it is possible to force kill the process.

By killing a process, it will be forced to close immediately, meaning if it were just saving, Ubuntu would terminate the process without waiting. This sudden termination could potentially lead to data loss or system instability.

You should typically only kill a process on Ubuntu if it no longer responds to normal stop commands.

Over the next few sections, we will show you how to kill a process on Ubuntu using the terminal or desktop interface. Both methods are relatively easy to utilize.

How to kill a process on Ubuntu Using the Terminal

This section will show you how to kill a process on Ubuntu using only the terminal. This is useful where you don’t have access to the graphical interface, such as when using Ubuntu server or an SSH connection.

If you happen to be using a desktop variant of Ubuntu, you can open the terminal by pressing CTRL + ALT + T.

There are three different commands that we will be covering within this section.

  • One is the kill command that allows you to kill individual process IDs.
  • Another is the killall command that allows you to kill all processes with a particular name.
  • The final command is pkill. Like killall, you will only need to know the name of the process.

Please note that if you are trying to kill a process on Ubuntu that doesn’t belong to your current user, you will need superuser privileges. Therefore, ensure you use “sudo” in front of any of the commands that we will be discussing below.

Using the kill Command to Terminate a Process ID

To terminate a process, we will be using the aptly named kill command. This tool allows you to kill a process both gracefully and suddenly by controlling the signal it sends.

Getting the ID of a Process

1. To kill a specific process on Ubuntu, you will need to know its process ID.

The easiest way to get the ID of a process is by utilizing the pidof command. However, if you want to kill a process consuming a lot of memory or CPU it might be easier to use the top command to find the correct IDs.

All you need to do to get the process ID of a specific process is to use “pidof” followed by the name of your process.

For example, if we wanted to get the process ID of Firefox, we would use the following command.

After running this command, we got a list of the following process IDs belonging to Firefox. Since we can kill more than one process at a time on Ubuntu, we will copy all of the listed IDs.

Kill a Process using its ID

2. Killing a process on Ubuntu is straightforward once you have its ID.

First, you need to decide if you want to allow a graceful closure of that process (SIGTERM) or to force kill it (SIGKILL).

To perform a graceful kill of a process on Ubuntu you just need to use “kill” followed by any IDs you want to close.

For example, if we wanted to kill all of the IDs belonging to Firefox on our system, we would use the following.

3. If your processes on Ubuntu won’t terminate despite being sent a graceful terminate, then you will have to use “SIGKILL“.

By sending “SIGKILL“, Ubuntu will kill the process without giving it the chance to gracefully shut down.

You can use the same kill command as before, but this time you will use the option “-s SIGKILL“.

For example, we would utilize the following to force kill the Firefox process’s running on our Ubuntu system.

Using the killall Command to kill a Process on Ubuntu

One of the other options that you can use to kill a process on Ubuntu is the killall command. This command doesn’t expect process IDs and instead expects you to specify the

This command will find and close all processes on Ubuntu that start with that specified name.

1. The syntax for using this command on Ubuntu is as straightforward as typing “killall” followed by the process name.

When used without any arguments, this will only send a “SIGTERM” to processes allowing them to close gracefully.

For example, to kill all processes that have the name “firefox” you could use the following command.

2. Of course, not all processes will want to close gracefully, leading to a stuck process.

To work around this, you can use killall to use “SIGKILL” which will force kill that running process on Ubuntu. Be careful running, this as it can lead to data loss and other unexpected behaviours.

All you need to do is use “killall“, followed by the “-s SIGKILL” option, then the processes name.

For example, we would use the following to force terminate all processes using the name “firefox” on our Ubuntu system.

How to use the pkill Command on Ubuntu

The final command that we will be discussing is the pkill command. This command allows you to kill a specific process on Ubuntu by only providing its name.

1. Using this command is simple, as you don’t have to worry about finding the ID of a specific process. Instead, you only need to know its name.

To attempt a soft kill of a process, you just need to use “pkill” followed by the process name.

For example, to kill a process that has the name “firefox,” you will utilize the following in the terminal

2. A soft kill of a process will only work if it reponds in the first place. If it isn’t responding, you will instead want to send a “SIGKILL” signal to the process.

When you use the “SIGKILL” signal, Ubuntu will immediately kill the process regardless of what that process is currently doing.

To force kill a process using only its name within the terminal you would use the following.

For example, to force kill a process on Ubuntu that uses the name “firefox“, we would use the command below.

How to Kill a Process on Ubuntu using the Desktop Interface

This section will show you how you can kill a process on Ubuntu using the desktop interface.

You can easily kill a process thanks to a piece of software that comes bundled with the desktop variant of Ubuntu. This software is called the “System Monitor”.

1. To start, we will need to open the activities screen on your Ubuntu device.

To open this screen, you need to click the top or bottom left of your screen.

Open Activities Screen

2. With the activities screen open, use the search box at the top of the screen to search for “System Monitor” (1.).

Once “System Monitor” appears, click the icon (2.) to open the application. This is the application that will allow us to kill a process from Ubuntu’s desktop.

Open System Monitor

3. With the System Monitor tool open on your device, identify the process you want to kill and RIGHT-CLICK it (1.).

There are a few options (2.) you can use to kill the process on Ubuntu. We will quickly go through them.

If you only want to end a process cleanly you can just click the process you want to kill (1.), then click the “End Process” button (3.).

Select Process to Kill on Ubuntu

4. Before Ubuntu kills the process you will get a message like the one, we have shown below. This message will differ if you select an option different from “Kill“.

To proceed, you will need to click the “Kill Process” button.

Confirm Kill Process

Conclusion

At this point, you should now understand how you can kill a process on Ubuntu.

We have covered both command line, and GUI steps to stop a running process on your system. Both are relatively straightforward to use once you understand what commands or tools to use.

Please comment below if you have questions about killing a process on Ubuntu.

Be sure to check out our many other Ubuntu guides. We also have a wealth of other tutorials that help you with general Linux usage.

Print Friendly, PDF & Email
Spread the love

Server Status

Aradippou Chat 1 Chat 2 Larnaca Limassol Nicosia

Chat Links

Official Links.

1. Chat 1.
2. Chat 2.

Alternative Mirror Links.

1. KiwiIRC 1.
2. KiwiIRC 2.

Other Web Clients.

1. IrcCloud.

Recent Posts

Related Posts:

Archives

Super Club Radio

CyIRC

CyIRC Tweets

Scroll Up