As a webmaster administrating a server you may often run into errors with file and process locks – in that case it is handy to know how to kill a process on CentOS and other Linux distributions.

Finding The Process

1. Open up putty or whatever app you use to connect to your SSH shell

2. If you want to kill a yum process for example, let’s first get the process id, to do that we don’t have to know much:

ps aux | grep yum
ps aux | grep process
ps aux | grep apt-get
ps aux | grep named

“ps aux” fetches all processess currently running on CentOS and grep is a tool to locate text/strings. Yum is the default package installer on CentOS (the equivalent on Ubuntu is apt-get install)

3. Alright we will get something similar to this, where we see the process ID of all yum process that are currently running

Run Ps Aux To Fetch Process List.png


4. The syntax to kill a process on CentOS is fairly simple and straight-forward:

kill SIGNAL processID 

(where processID needs to be replaced with the actual ID and SIGNAL is an OPTIONAL parameter)

There are 3 SIGNALS:

  1. -1 (process hangs, reload kill)
  2. -9 (not recommend, force kill)
  3. -15 (default, safe kill)

Always try the default first which looks like kill ProcessID

If you want to know more about SIGNALS, read this Wiki Article

Killing The Process: Example

Default, safe kill

kill 25632

Force kill:

kill -9 25632


kill -1 25632

Yum Processes: Force Kill Required By Root

If some of your YUM processes get stuck, it is OFTEN required to force kill the process, everything else won’t work

Root User Force Kills Process.png

In my case, I had to force kill the process using the SIGNAL -9 and voilĂ  the process was killed successfully. In some cases, you may need to be logged in as a root user to kill the process. If you are not logged in as a root user you can’t kill processes initiated by other users. You also need root privileges to kill a system process

Questions? Let us know in the comments