Linux Commands

How to Check and Kill Running Processes in Linux Mint 21

In Linux Mint 21, checking and killing running processes can be done using various command line tools. It is important to know how to manage running processes in order to free up system resources and troubleshoot issues. This guide will cover how to check and kill running processes in Linux Mint 21.
Content of this article include:

How to Check Running Processes in Linux Mint 21

If you want to view a list of all the processes currently running on your Linux Mint 21 system, there are a few methods you can use. Now we will cover all methods in detail.

[ps] Command to Check Running Processes in Linux Mint 21

To display a list of running processes on Linux Mint 21 system, you can use the ps command. This command displays useful information such as the process ID (PID) and other details on the terminal:

ps -aux

In above command the flag -aux will list all running processes including the one which are running in background.

Current running all processes are display as below:

The [ps -A] can also display information about all processes on the system, including those not associated with terminals.

ps -A

Another way to achieve the above goal is to use the grep command, we can check the current running instances of a certain process by using the process name:

ps aux | grep [process-name]

For example, to check all running instances of gnome-calculator use:

ps aux | grep gnome-calculator

[pstree] Command to Check Running Processes in Linux Mint 21

The pstree command can display a tree-like diagram of running programs on the system. Run the below command to display all running program in a tree shape format:

pstree

The output of above command is as follows:

[top] Command to Check Running Processes in Linux Mint 21

The top utility is a powerful command-line tool in Linux Mint 21 that displays a real-time list of all the running processes on your system. This tool provides information, including the process ID (PID), CPU and memory usage, and much more.

Run below command to check details of all running processes in Linux Mint 21:

top

Above command will give us the list of running processes of our Linux Mint 21 system:

To exit the top utility interface, use the Ctrl + C key.

[htop] Command to Check Running Processes in Linux Mint 21

The htop utility is an advanced version of the top utility. The htop has more detailed on current process with better interface. This utility also helps to retrieve information about all current running processes in your system.

By default, htop is not available in Linux based systems. To install it in Linux Mint 21 run:

sudo apt install htop

After installation, you can easily view the running processes by executing the htop command.

htop

The output is visually more appealing, with catchy colors displaying the same statistics as the top utility. To exit press Ctrl + C.

How to Kill Process Using [kill], [pkill] and [killall] Command in Linux Mint 21

To kill a process in Linux Mint 21 we can use different commands such as kill, pkill and killall. Using all these commands we can either terminate a single process or shutdown all instances of a certain process. Now we will describe all three commands in detail.

Kill a Process Using [kill] Command

The kill command stops or kills a process. This command sends a signal to the specified process, causing it to stop executing and exit.

The common syntax for kill command is:

kill [signal or option] [PID]

By default, the kill command sends a SIGTERM [-15] signal, which completely stops and cleans the process before exiting. However, it is also possible to send a SIGKILL [-9] signal, which immediately terminates the process without allowing it to clean up.

Multiple signals are there to use with the kill command. You can list all the signals using:

kill -L

Following above all the three SIGNALS are commonly used with kill command:

Signal Name Signal Value Behavior
SIGHUP 1 Hangup
SIGKILL 9 Kill Signal
SIGTERM 15 Terminate

From above three SIGNALS the SIGTERM [-15] is the safest way of killing a process. The SIGHUP [-1] is less secure than SIGTERM. And lastly the SIGKILL [-9] is the most unsafe way that terminates the process without saving.

To kill a certain process its Process ID must be known. Processes are instances of programs. A unique PID is generated for each program at its start.

For killing a certain process with the help of its process ID [PID] use:

kill [PID]

Or we can also send:

kill -9 [PID]

A [SIGKILL-9] signal will be sent to process by above command.

To know the process ID, we use following command:

pidof [process name]

For example, killing a process having PID [2703]:

kill -9 2703

Alternatively, we can also use the [ps -aux] command to check process PID as discussed above:

ps -aux

Kill a Process Using [killall] Command

The killall is much similar to kill command, but it terminates all processes with a given name. By default, killall sends the SIGTERM [-15] signal to each process, but this can be changed with the -s option.

This command is used to kill all instances of a particular process.

killall [signal or option] [process name]

Here’s an example of how to use the killall command:

Here we have opened a new terminal and ping Google using below command:

ping google.com

Similarly, we then ping bing.com in a new terminal using command:

ping bing.com

Then to kill all two-ping process with killall command run:

killall ping

This command would send the SIGTERM [-15] signal to all processes with the name ping and terminate them.

Kill a Process Using [pkill] Command

The pkill command is a utility used in Linux based operating systems to send signals to running processes based on their name or other attributes. It can be used to terminate a process using the process name.

The pkill command is similar to killall, but it allows for more complex pattern matching when selecting processes to terminate. The pattern can be specified using regular expressions.

The syntax for pkill command is:

pkill [process name]

Here’s an example of how to use the pkill command:

To kill all three instances of Firefox run following command:

pkill firefox

How to Kill More Than One Process in Linux Mint 21

To kill more than one process we must know the process ID [PID] for all the running processes. Using the below given syntax we can easily kill multiple process using a single command:

kill [PID1] [PID2] [PID3]
or
kill -9 [PID1] PID2] PID3]
or
kill -SIGKILL [PID1] [PID2] [PID3]

For example, to kill the gnome-calculator and Firefox we first check the pid for both and then kill them using single kill command:

kill -9 4847 4617

Conclusion

Checking and killing running processes in Linux Mint 21 is a simple and easy task that can be done using simple commands in the terminal. By using the top command, users can identify resource-intensive processes, while the kill command can be used to terminate them. To get details on all these commands read the article.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.