How To's

How to kill a process in Linux

3,863 views · 0 found this helpful · 1 did not

Was this helpful?

Problem

Kill a running process that is blocking another one from executing

tl;dr

List running processes

ps

Kill offending process where 12345 is the PID of the offending process

kill -9 12345

Solution

Sometimes you may see an error message, such as:

[root@ess001010]# yum install httpd -y
Loaded plugins: fastestmirror, security
Existing lock /var/run/yum.pid: another copy is running as pid 21544.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: yum

This happens when a process has been started, in this case yum, but it has not been shut down properly. To see currently running processes on Linux (any version), type:

ps

You will see a screen such as this one:

[root@ess001010]# ps
PID TTY TIME CMD
9098 pts/0 00:00:00 bash
21544 pts/0 00:00:00 yum
21597 pts/0 00:00:00 yum
21644 pts/0 00:00:00 ps

What you need to do is kill the pesky "yum" processes residing in your memory. To do that, type in:

kill -9 21544

Where 21544 is the PID (process ID). You can find PID in the left-most column of running processes. In this case, it's 21544.

  • Updated

← All articles

Still stuck?

Our engineers answer tickets directly, 24/7.