Steps to Kill a Process in Linux/Unix

January 28, 2012 / Dedicated Server

A computer process refers to a computer program having a unique process identification or also called as PID. Basically, on the Linux operating system, a process may be running in the background, foreground or may be in a suspended state. It might possible that on Linux, the OS shell may not return the prompt to the end-user unless the current process that is running is finished. As a result, many processes that take a substantial amount of time to execute and keep you from utilizing the console until the process is finished running.

The most common issue that arises for Linux users is to kill or background a process so that other tasks are conducted on the system. In order to kill a process, a signal has to be sent using the Linux kill command.

How to kill a Linux process using “kill” command?

Step 1: Enter the below Linux command to get the PID for the running process on your system which you want to kill.

ps myProcess

Once you enter the above command it will return with something similar to the following:

PID TTY TIME CMD
1234 dz07 0:50 edit myBook
1235 dz07 0:47 -csh

Step 2: Enter the following Linux kill command to terminate the first process mentioned in the example above:

kill -1 1234

Enter the following command to terminate the second active process:

kill -1 1235

Step 3: It is possible that the kill -1 does not work, in such a case, you will need to use the -9 argument to clear the process from your system. Use the following command:

kill -9 1234

kill -9 1235

Step 4: Instead you can also kill all the instances of a given process by using the killall command. Enter as shown below:

killall <pname>
<pname> refer to the process name.

This tutorial is applicable only on VPS or a Dedicated Server, as it requires root access to the server.

Spread the love