kill command in Linux with Examples

kill command in Linux (located in /bin/kill), is a built-in command which is used to terminate processes manually. kill command sends a signal to a process which terminates the process. If the user doesn’t specify any signal which is to be sent along with kill command then default TERM signal is sent that terminates the process.

Options and examples

1. kill -l :To display all the available signals you can use below command option:

Syntax:

$kill -l

Signals can be specified in three ways:



  • By number (e.g. -5)
  • With SIG prefix (e.g. -SIGkill)
  • Without SIG prefix (e.g. -kill)

Note:

  • Negative PID values are used to indicate the process group ID. If you pass a process group ID then all the process within that group will receive the signal.
  • A PID of -1 is very special as it indicates all the processes except kill and init, which is the parent process of all processes on the system.
  • To display a list of running processes use the command ps and this will show you running processes with their PID number. To specify which process should receive the kill signal we need to provide the PID.

    Syntax:

    $ps
    

2. kill pid : To show how to use a PID with the kill command.

Syntax:

$kill pid

3. kill -s : To show how to send signal to processes.

Syntax:

kill {-signal | -s signal} pid 

4. kill -L :This command is used to list available signals in a table format.

Syntax:

kill {-l | --list[=signal] | -L | --table} 


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.