How to force kill a process in linux

You may occasionally need to kill a process in linux. The “kill” command in linux will do the job well. Combine kill with the “ps” command and you can easily remove any process.

First use the ps to get a list of the current processes

# ps -ef | grep ssh
root      2504  1363  0 20:54 ?        00:00:00 sshd: root@pts/0

Here is an ssh process we want to kill. To kill it we do

# kill 2504

On occasion the default kill signal may not work. To force kill a process you can use

# kill -9 <process id>

Use this carefully since it can have adverse results.