Linux command: kill

Quick startkillCommand, used to send a signal to the currently running process

Linux process can receivesignalReact to them.

This is a way for us to interact with the running program.

ThiskillThe program can send various signals to the program.

It is not only used to terminate the program, as its name implies, but it is its main job.

We use it in this way:

kill <PID>

By default, this will sendTERMSignal to the specified process ID.

We can use flags to send other signals, including:

kill -HUP <PID>
kill -INT <PID>
kill -KILL <PID>
kill -TERM <PID>
kill -CONT <PID>
kill -STOP <PID>

HUPmethodhang up. This message will be sent automatically when the terminal window that started the process is closed before terminating the process.

INTmethodinterrupt, It will send the same signal as when we pressedctrl-CIn the terminal, the process is usually terminated.

KILLNot sent to the process, but sent to the operating system kernel, which immediately stops and terminates the process.

TERMmethodtermination. The process will receive it and terminate itself. This is the default signal issued bykill.

CONTmethodcarry on. It can be used to resume a stopped process.

STOPNot sent to the process, but sent to the operating system kernel, the operating system kernel immediately stops (but does not terminate) the process.

You may see numbers used instead, such askill -1 <PID>. under these circumstances,

1Corresponds toHUP.2Corresponds toINT.9Corresponds toKILL.15Corresponds toTERM.18Corresponds toCONT.15Corresponds toSTOP.

This command can be used in Linux, macOS, WSL and wherever you have a UNIX environment

Download mine for freeLinux Command Manual


More cli tutorials: