Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between kill and kill -9?

What is the difference between kill and kill -9 on the Linux command line?

like image 670
tonyjosi Avatar asked Dec 05 '25 19:12

tonyjosi


2 Answers

kill aka kill -TERM aka kill -15 is the safe and correct way of terminating a process. It's equivalent to safely shutting down a computer.

kill -9 is the unsafe way of brutally murdering a process. It's equivalent to pulling the power cord, and may cause data corruption.

See the Linux&Unix stack exchange for more information.

like image 52
that other guy Avatar answered Dec 08 '25 15:12

that other guy


kill is a utility program, found in Unix-like operating systems, for sending different signals to one or more processes (usually, for terminating, pausing, continuing, etc. – manipulating processes).

When executing kill without any signal number (which is sometimes referred to as a signal code), the default signal number 15 will be used and that is equivalent to the SIGTERM signal name.

One other signal number is 9, which is equivalent to the SIGKILL signal name.

The difference between kill -15 PID (which is same as kill PID) and kill -9 PID is that the first shuts the specified process down gracefully and the second does that forcefully, killing the process and all its subprocesses.


Generally, for killing specific process, you can use kill in one of four alternative fashions:

  • kill -signalnumber PID
  • kill -s signalnumber PID
  • kill -SIGNALNAME PID
  • kill -s SIGNALNAME PID

(PID stands for Process ID)

like image 35
Giorgi Tsiklauri Avatar answered Dec 08 '25 15:12

Giorgi Tsiklauri