No matter which operating system you use, you will surely encounter a misbehaving application that locks itself down and refuses to close it. On Linux (and Mac), you can force it to end using a "kill" command. In this tutorial, we will show you multiple ways to use the "kill" command to terminate the application.
Kill command and signal
When you execute a "kill" command, you actually send a signal to the system to let it terminate the abnormal application. There are a total of 60 signals that you can use, but basically you only need to know SIGTERM(15) and SIGKILL(9).
You can use this command to see a list of all signals:
Kill -l
SIGTERM - This signal requests a process to stop running. This signal can be ignored. A process can be shut down normally for a period of time. Normal shutdown of a program usually takes a while to save progress and release resources. In other words, it is not forced to stop.
SIGKILL - This signal forces the process to stop running immediately. Programs cannot ignore this signal and 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 use the following command to force kill a process:
Kill SIGKILL PID
or
Kill -9 PID
Here "-9" represents the SIGKILL signal.
If you do not know the PID of the application, just run this command:
Ps ux
It will show all running applications and application PIDs.
For example, to kill Chrome, I run the command:
Kill -9 3629
You can also kill multiple processes at the same time.
Kill -9 PID1 PID2 PID3
PKill
The "pkill" command allows the use of extended regular expressions and other matching methods. You can now use the app's process name to kill them instead of using PIDs. For example, to kill the Firefox browser, just run the command:
Pkill firefox
Using regular expression matching, you can enter some characters of the process name, such as:
Pkill fire
In order to avoid killing the wrong process, you should use the "pgrep -l [process name]" list to match the process name.
Killall
Killall also uses the process name instead of PID, and it kills all processes with the same name. For example, if you are running multiple Firefox browser instances, you can kill them all with the command:
Killall firefox
In Gnome, you can use this command to restart Nautilus:
Killall nautilus
Xkill
Xkill kills an application graphically. When you type "xkill" at the terminal, your cursor will immediately become a "cross". All you have to do is click on an unusual application and it will immediately kill the application. If you often use it, you can also add a keyboard shortcut to activate xkill.
in conclusion
When the application is abnormal and causes the system to hang, people often restart the computer and start all tasks again. With these "kill" commands, you will be able to better deal with abnormal applications, so as to avoid causing the system to crash. This is especially useful when you don't want to crash the server due to an abnormal process.
60V Battery Pack ,Battery Pack With Outlet,Back Up Battery Pack,Ev Battery Pack
Zhejiang Casnovo Materials Co., Ltd. , https://www.casnovo-new-energy.com