Forum Stats

  • 3,722,431 Users
  • 2,244,306 Discussions


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to kill process in Unix/Linux?

JimTerry Member Posts: 20 Green Ribbon

There are different options to terminate a process in Unix/Linux flavour of operating systems. This article intends to list down those options.


You can use the ‘kill’ command to terminate a process by passing the ‘process id’. 

kill {PID}

PID – is the ‘process Id’ of the process that you want to terminate. If you are not sure how to find ‘process Id’, refer to this article.


Suppose if you want to kill a process whose ‘process Id’ is 1692 then command would be:

kill 1692

Sometimes when you issue the ‘kill’ command you may get an ‘operation not permitted’ error message. In those circumstances, issue kill command with ‘-9’ signal. i.e.

kill -9 {PID}
kill -9 1692

If you continue to get an ‘operation not permitted’ error message even with ‘kill -9’ signal then you may not have sufficient permission to terminate the process. Then you need to ‘sudo’ as a ‘root’ user (i.e. login as a super user) and then issue the ‘kill -9’ command.

NOTE: This is the same as the ‘run as administrator’ option in Windows.

Fig: Terminating the process with ‘kill -9’ signal


 ‘killall’ command is another option to terminate multiple processes in one stroke. You can use this option to kill processes based on their names, users who launched them. Let’s explore all ‘killall’ options in this section. 

a. killall process_name: Kill processes that match the specified process name. 

killall {ProcessName}

Suppose if you want to kill the Process whose ‘process name’ is ‘java’, then command would be:

Fig: killall processname

NOTE: Say if 3 processes are running with the name ‘java’, then when you use ‘killall’, all the 3 processes will be terminated.

b. killall -I process_name: Ignore case when trying to find the process name.

killall -I {ProcessName}

Suppose if you want to kill the Process whose ‘process name’ is ‘java’, but if you are not sure about the case sensitivity of the process, then you can use ‘-l’ option:

killall -I JAVA

c. killall -i process_name: Ask for additional confirmation when killing the process.

killall -i {ProcessName}

Suppose if you want to kill the Process whose ‘process name’ is ‘java’, it needs to ask for confirmation, then command would be: 

Fig: Killall Confirmation

d. killall -u username: It kills processes owned by a specific user.

killall -u {UserName}

Suppose if you want to kill all the Process owned by the username ‘ec2-dev’, then command would be:

killall -u ec2-dev

e. killall -v process_name: Report back on whether the process has been successfully killed.

killall -v {ProcessName}

Suppose if you want to kill the Process whose ‘process name’ is ‘java’ and you wanted to know whether the process is successfully killed, then command would be:

Fig: Process Killed Reported


You can use ‘pkill’ command to terminate process(es) by sending a fullname or partial name of the process. By default pkill will send the signal SIGTERM.

pkill {ProcessName}

Suppose if you want to kill the Process whose ‘process name’ is ‘java’, then command would be:

pkill java

Difference between ‘killall’ and ‘pkill’

‘killall’ will look for the exact match of the process name whereas the ‘pkill’ will allow to terminate the process either by full name or partial process name.

EXAMPLE: There is a process with the name ‘java’. If you try to terminate the process using ‘killall’ command by giving partial name i.e. ‘ava’ then you will get ‘no process found’ error:

Fig. killall using partial process name

On the other hand iIf you try to terminate the process using ‘pkill’ command by giving partial name i.e., ‘ava’, it will succeed:

Fig. pkill using partial process name


You can also terminate a process using the popular system monitoring tool – ‘top’. Below are the steps to terminate a process in ‘top’:

1. Press ‘k’ key when top command is running

2. It will ask you to enter the Process Id which you want to terminate

3. Type the Process Id 

4. Then it will ask you the signal you want to use for killing the Process

5. Type ‘9’ which is a SIGKILL. By default the signal will be SIGTERM (‘15’). If you would like to know the difference between SIGKILL and SIGTERM, refer to the below section (‘Difference between SIGTERM, SIGKILL’) in this article. 

6. press enter

Fig: killed using SIGKILL signal


  • nihitthakkar
    nihitthakkar Member Posts: 92 Red Ribbon

    There's more than one way to kill a Unix process

    1. Ctrl-C sends SIGINT (interrupt)

    2. Ctrl-Z sends TSTP (terminal stop)

    3. Ctrl-\ sends SIGQUIT (terminate and dump core)

    4. Ctrl-T sends SIGINFO (show information), but this sequence is not supported on all Unix systems.

    Command examples to kill a process on Linux

    Step 1 – Find out the PID (process id) of the lighttpd. Use the ps or pidof command to find out PID for any program.

    Step 2 – kill the process using a PID.

    Step 3 – How to verify that the process is gone/killed.

Sign In or Register to comment.