How To Kill Process In Linux

by lifeLinux on May 21, 2011

Sometimes, I need to kill a process in Linux. So, how can I do that ? In this article, i will explain how do I kill process in Linux.

Kill process using PID (Using kill command)

kill command sends a signal to a specified process. If no signal is specified, the TERM signal is sent. The TERM signal will kill a process. For a list of possible signals, type ‘man 7 signal’ in a terminal window.
First you must determine the PID of the process you want to kill. This can be done usually pretty easily with the ps command in Linux. Example, find process ID of mysqld, type the following command

# ps aux | grep mysql


mysql     1815  0.0  0.2 254112  3844 ?        Ssl  May16   0:51 /usr/sbin/mysqld

Finally, kill process using PID. Above command tell you PID (1815) of mysqld process. Now kill process using this PID:

# kill 1815


# kill -9 1815

Note: “-9” option is special Kill signal which will kill the process and cannot be blocked. Do not issue “kill -9” to a process connected to a database or to a database engine process.

Using top command

Example, I will kill mysqld process, First, type the following command as root

# top

On screen, process id of mysql is 1815. I will press “k” and enter: 1815 to kill mysqld process. The screen will look like
Kill Process With Top Command

Kill processes by name

You can use killall command. The killall command kill processes by name. Example kill mysqld processes, type the following command

# killall mysqld


# killall -9 mysqld

Related Posts:

Previous post:

Next post: