Linux Mint – Killing processes

How to install Ubuntu Server 19.10

Processes, also known as daemons, are programs that run on your system in the background, providing a service or allowing a particular function to work. In order to view how running processes affect your system, you can use Mint’s System Monitor or the top command to get a look at what’s running on your system. Most likely, you will not know what the majority of them are for, and this is okay, since you’re not expected to. However, if your system starts running slowly or your system’s temperature starts increasing (which you’ll recognize by the increasing speed of the system’s fan), a running process may be to blame. If you see a process using 100 percent of your CPU, there’s a good chance that it may be to blame for sluggish performance.

Developers do their best to make sure that the programs and daemons don’t negatively impact the system, but the unfortunate reality is that bugs can and do sometimes happen. This is not even specific to Linux, as sometimes, bugs may affect all platforms. For example, your author has experienced an issue in Gmail once that caused the CPU usage of a single core to spike from 90 percent to 100 percent for no apparent reason. When the bug was reported, even those using Mac OS X and Windows saw the same unfortunate behavior. When this happened, it was easy to pinpoint that the web browser was the source of the erratic CPU usage, as the top command would show the browser eating an abnormal amount of CPU.

Due to the inherent imperfection of computing, it’s always a good idea to watch for strange behavior and to monitor resources when an unusual behavior is observed. The top command is one way of doing this, but Linux Mint also includes the System Monitor, available in the Applications menu, which suits the same purpose, although graphically. After opening the System Monitor, take a look at the Resources tab to see if any of your resources show abnormal usage (such as high CPU or memory usage) and also take a look at the Processes tab to see what’s running on your system. The following screenshot shows Mint’s System Monitor in the Cinnamon edition:

On the Processes tab, you can sort the running processes by the resources they are using. For example, if you click on CPU, then you will sort the process list by showing these processes that use the largest amount of CPU first. This way, you can easily pinpoint which process is stealing away your resources.

Note

You don’t have to check your resources unless there is an issue. Typical warning signs include your computer’s fan speeding up and staying on for an unusual amount of time, your system running slower than normal, applications misbehaving, or your machine seeming to feel warmer than normal.

When you right-click on a running process, you’ll have an option to kill the process. Should the related application not respond to close events (clicking on the x in the top-right corner of the window), killing an application through the System Monitor is another option that you may try. The following screenshot shows the Processes tab of the System Monitor, with the right-click menu:

Killing applications through the System Monitor isn’t the only way to close events. If you’re currently using the shell, you can kill an application in one of the several ways that are mentioned in this section. First, you can use the killall command. For example, to kill the Firefox web browser, you can use the following command line:


killall firefox

Killing an application with the killall command is not advised unless the application cannot be closed any other way. Applications may save data when you close them. This would not occur if you kill the application. If an application has completely frozen, the killall command may save the day. To kill all instances of an application, consider prefixing the killall command with sudo. If this still doesn’t work, it may be easier to restart the system at that point.

If you’re working in the shell and not a graphical environment at all, the System Monitor would be of no use to you, since it’s a graphical application. The top command, as mentioned earlier, is a very popular method to see what’s running on a system outside of a graphical environment. With it, you can see what’s running and what resources processes are taking up. Press the letter Q on your keyboard when you have finished using top. The following screenshot shows the top command running inside a terminal:

In addition to top, there is also the ps command. The ps command is simpler. It only prints a list of all the running processes on your system. Unlike the top command, the ps command doesn’t continually get updated; it simply prints a quick list of all your running processes and then returns you to the shell prompt. Go ahead and execute the following command on your system for a quick example:


ps -ax

Immediately, you’ll see a list of running processes. On the left-hand side, you’ll see the PID (process ID), which is a unique number given to each process. Although it may be easier to use the killall command against an application’s name, you can also use the kill command against the process ID in much the same way. For example, to kill process 26218 using the kill command, all you have to do is type kill and then 26218, as shown in the following statement:


kill 26218

If the process still won’t close, there is another, last-resort command you can try. The command is as follows:


kill -9

The -9 flag causes the program to close without an opportunity for cleanup. For example, consider the following statement:


kill -9 26218

If kill -9 doesn’t help you, force close a program; try to run the command line as the root user, or you can just restart your system.

Comments are closed.