Kill the Linux command

Source: Internet
Author: User
Tags pkill

Linux-Proficient KILL command

  
No matter which operating system you use, you must 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 execute a "kill" command, you actually send a signal to the system to let it end up with an unhealthy application. There are a total of 60 signals 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 running. This signal can be ignored. Processes can be closed for a period of time, and a graceful shutdown of a program typically 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. 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.
If you do not know the PID of the application, you only need to run this command:
PS UX | grep Firefox
It shows all running apps and the PID of the application.

For example, to kill Chrome, I would 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 you to use extended regular expressions and other matching methods. You can now kill them using the app's process name instead of using the PID. For example, to kill the Firefox browser, you only need to run the command:
Pkill Firefox
With regular expression matching, you can enter some characters of the process name, such as:
Pkill fire
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 to replace the PID, and it will kill all processes with the same name. For example, if you are running multiple instances of a Firefox browser, you can kill them all with a command:
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 become a "cross". All you have to do is click on an unhealthy app and it will kill the app immediately. If you use them frequently, you can also add a keyboard shortcut to activate Xkill.
Conclusion
When a system hangs due to an unhealthy application, people often restart the computer and start all tasks again. With these "kill" commands, you will be able to better handle the unhealthy applications, thus preventing the system from crashing. It is especially useful when you don't want to cause a server outage due to an unhealthy process.

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

Dylan presents.

 

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.