Would you like to learn how to deal with an unresponsive process on Linux? The kill and pkill commands will help you with this.

Dealing with unresponsive programs can be a difficult task, especially when you're running on older hardware. In this case, system freezing becomes a common problem. Fortunately, there are many ways to kill unresponsive processes in Linux.

The kill and pkill commands provide simple but effective solutions for killing unresponsive zombie processes from the terminal. The following sections describe how to terminate hanging processes with kill and pkill under Linux.

End unresponsive processes with kill

You can easily kill unresponsive processes using the kill command in Linux. It sends a completion signal to the process. By default, kill sends the SIGTERM Signal represented by signal number fifteen. The following example uses kill to stop a process with a PID of 27065.

kill 27065

Users can send other signals by specifying the signal name or number. For example, the following kill commands stop a zombie process with the SIGKILL System signal, represented by signal number 9.

kill -9 27065
kill -SIGKILL 27065

The difference between SIGTERM and SIGKILL is that processes can intercept and ignore the SIGTERM signal. However, SIGKILL is immune to the processing of processes and terminates programs immediately.

You can view a list of all available signals by using the kill commands below.

kill -l
kill -L

Overall, SIGKILL is better suited for dealing with unresponsive system processes. On the other hand, SIGTERM is the way to go if you want to properly terminate hanging programs.

End unresponsive processes with pkill

The pkill command makes it easier to kill processes on Linux by allowing us to kill programs based on their name. For example, the following command kills the nano Program with pkill.

pkill nano

Like kill, pkill also sends the SIGTERM signal by default. Use the SIGKILL signal when you want to stop the unresponsive process immediately.

pkill -9 nano

How to get the process ID (PID) of a process

The PID information can be of great help in killing unresponsive processes on Linux. There are several ways to get a process's PID number. The following command gets the PID of a process named nano using the grep and ps commands.

ps aux | grep nano

You can also use the pgrep command, which spits out the process ID directly.

pgrep nano

Manage unresponsive processes on Linux

The kill and pkill commands make dealing with unresponsive processes on Linux easy. All you need to stop a zombie process is its PID and access to a shell. However, you may need additional sudo permissions when killing processes owned by another user. So if you are on a multi-user system, ask the administrator to add you to the sudoers list before doing anything.

How to add a user to the sudoers list in Linux

Would you like to grant administrator rights to a Linux user? This is how you can add a user to the Sudoers list.

Continue reading

About the author

Rubaiat Hossain
(24 articles published)

Rubaiat is a CS graduate with a strong passion for open source. Aside from being a Unix veteran, he's also into network security, cryptography, and functional programming. He is a passionate collector of used books and has an endless admiration for classic rock.

More
By Rubaiat Hossain

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email you just sent.