This article explains how to kill a process in Linux/Unix. A computer process is a program with a unique process ID (PID). On Linux, a process can run in the background, foreground, or be suspended. Sometimes, the OS shell may not return the prompt until a running process is completed, delaying console use. To address this, users often need to kill or background a process to continue other tasks. The Linux kill command is used to send a signal to terminate a process.
Follow the steps to kill a process using the “kill” command:
- 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 something similar to the following:
PID TTY TIME CMD 1234 dz07 0:50 edit myBook 1235 dz07 0:47 -csh
- 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
- 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
- Instead, you can also kill all the instances of a given process by using the killall command. Enter as shown below:
killall <pname>
Note: <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.