Kill the Linux command

Source: Internet
Author: User
Tags pkill

Linux-Proficient KILL command

  
Regardless of which operating system you use, you will definitely encounter an application that is behaving erratically, locking itself down and refusing to shut down. On Linux (and Mac). You can force an end to it with a "kill" command. In this tutorial, we'll show you a variety of ways to use the KILL command to end your app.
Kill command and Signal
When you run a "kill" command, you actually send a signal to the system to let it end up with an unhealthy application. There are 60 common signals that you can use. But basically you just need to know Sigterm (15) and Sigkill (9).
You can use this command to see a list of all the signals:
Kill-l

? SIGTERM-This signal requests a process to stop executing. This signal is capable of being ignored. The process can gracefully shut down for a period of time. Normal shutdown of a program usually takes some time to save progress and release resources.

In other words, it is not forced to stop.
? SIGKILL-This signal forces the process to stop executing 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 use the following command to force kill a process:
Kill SIGKILL PID
Or
Kill-9 PID
Here "-9" represents the Sigkill signal.
Assuming you don't know the PID of the application, you only need to execute this command:
PS UX | grep Firefox
It shows all the applications that are being executed and the PID that is applied.

Like what. To kill Chrome, I'll execute the command:
Kill-9 3629
It is also possible to kill multiple processes at the same time.


Kill-9 PID1 PID2 PID3
PKill
The "Pkill" command agrees to use the extended regular form and other matching methods. Instead of using PID, you can now kill them using the app's process name.

For example, to kill the Firefox browser, you simply need to execute the command:
Pkill Firefox
With a regular table match, you can enter some characters of the process name, for example:
Pkill fire
To avoid killing the wrong process, you should use the "pgrep-l [process name]" list to match the process name.

Killall
Killall uses the same process name instead of PID, and it will kill all processes with the same name.

Like what. Suppose you are executing multiple instances of a Firefox browser and can kill them all with commands:
Killall Firefox
In GNOME, you can use this command to restart Nautilus:
Killall Nautilus
Xkill
Xkill is a graphical way to kill an application.

When you type "Xkill" in the terminal, your cursor will immediately turn into a "cross". All you need to do is click on an unhealthy application. It will kill the app right away. If you use it regularly, you can also add a keyboard shortcut to activate Xkill.
Conclusion
When the system hangs due to an unhealthy application, people often restart the computer and start all tasks again. And with these "kill" commands. You will be better able to handle unhealthy applications and avoid crashing the system. It's especially useful when you don't want to cause a server outage due to an unhealthy process.

--------------------------------

Dylan presents.

Kill the Linux command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.