How Linux uses the kill command to force a process to terminate

  
                

In the Windows system, if the application does not respond, we will start the task manager to terminate the application, while in the Linux system, use the kill command, the kill command is mainly used to force the process to close, the following small series will introduce you to Linux. The usage of the kill command.

Kill Commands and Signals

When you execute a <kill” command, you actually send a signal to the system to terminate the abnormal application. There are a total of 60 signals you can use, but basically you only need to know SIGTERM(15) and SIGKILL(9).

You can see a list of all signals with this command:

kill -l

? SIGTERM - This signal requests a process to stop running. This signal can be ignored. A process can be shut down gracefully for a period of time. A normal shutdown of a program typically takes a while to save progress and free up resources. In other words, it is not a forced stop.

? SIGKILL - This signal forces the process to stop running immediately. The program cannot ignore this signal and the unsaved progress will be lost.

The syntax for using “kill” is:

kill [signal or option] PID(s)

The default signal (when not specified) is SIGTERM. When it doesn't work, you can force a process to be killed by using the following command:

kill SIGKILL PID

or

kill -9 PID

Here “-9” represents the SIGKILL signal.

If you don't know the PID of your application, just run this command:

ps ux

Copyright © Windows knowledge All Rights Reserved