A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/kill-command-in-linux-with-examples/ below:

How to Kill a Process in Linux | Kill Command

How to Kill a Process in Linux | Kill Command

Last Updated : 26 Apr, 2024

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 that terminates the process. If the user doesn't specify any signal that is to be sent along with the kill command, then a default TERM signal is sent that terminates the process.

Basic Syntax of kill command in Linux

The basic syntax of the `kill` command is as follows:

Syntax :

kill [signal] PID

Here, 

Signals can be specified in three ways:

Signals can be specified in three ways; they are as follows:

1. By number:

We can specify a signal using a number. For example, we have a PID `1212` and want to send a `SIGKILL` signal to kill this PID. SIGKILL has a signal number of `9` (To find signal numbers run `kill -l` command).

Syntax:

kill -9 1212
2. With SIG prefix (e.g/ -SIGkill)

We can also specify signal using SIG prefix. For example, we need to send a signal `SIGTERM` and PID is `1432`. To just check signal number of `SIGTERM` signal we can use `kill -l` command.

Syntax:

kill -SIGTERM 1432
3. Without SIG prefix:

We can also specify signals without using SIG prefix. For example, if want to send signal `TERM` and PID `1234`. To just check signal number of `TERM` signal we can use `kill -l` command.

Syntax:

kill -TERM 1234
Some Common Signals in kill Command

The table below shows some common signals and their corresponding numbers.

Signal Name Signal Number Description SIGHUP 1 It hangup detected on controlling terminals or death of controlling process. SIGINT 2 It interrupts from keyboard. SIGKILL 9 It kills signal. SIGTERM 15 It terminates signal.

To check signal name and number we can use `kill -l` command.

Options and Examples of kill Command in Linux

kill -l Option

To display all the available signals, you can use the below command option:

 Syntax:

kill -l
kill -l

Note:

Syntax:

ps
ps kill PID Option

This option specifies the process ID of the process to be killed.

 Syntax:

kill pid
kill -s Option

This option specifies the signal to be sent to the process.

 Syntax:

kill {-signal | -s signal} pid 
Conclusion

The `kill` command in Linux is a very powerful utility for managing processes. We have understood the different ways to specify the signals and available options in the kill command which can help us to manage our system resources efficiently and resolve issues quickly and effectively.  



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4