Use the Xkill command in a Linux system to kill an unresponsive process

Source: Internet
Author: User
Tags resource pkill

How do we kill a resource/process in Linux? Obviously we'll find the PID of the resource and use the KILL command.

To be more clear, we can find the PID of a resource (such as terminal):

The code is as follows:

$ ps-a | Grep-i Terminal

6228? 00:00:00 gnome-terminal

In the output above, ' 6288 ' is the PID of the process (gnome-terminal), using the following command to kill the process.

The code is as follows:

$ kill 6228

The KILL command sends a signal to the PID process.

Another approach is that we can use the Pkill command, which can kill processes based on the name of the process or other attributes. And we're going to kill a process called terminal to do this:

The code is as follows:

$ pkill Terminal

Note: The length of the process name after the Pkill command is not greater than 15 characters

Pkill looks more easy to use because you don't have to find the process PID. But if you're going to have better control over the system, there's nothing you can do to defeat ' kill '. Use the KILL command to better examine the process you are about to kill.

For those who run X server, there is another tool called Xkill that kills a process from the X window without having to pass its name or PID.

The Xkill tool forces x server to shut down the connection to its client program, and the result is that X resource shuts down the client program. Xkill is a very easy to use tool for X11 tools to kill unwanted windows.

It supports options such as using the-display option to connect to the specified x server after running multiple x servers at the same time, using-all (not recommended) to kill all top-level windows on the screen, as well as frame (-frame) parameters.

To list all the client programs you can run:

The code is as follows:

$ xlsclients

Sample output

The code is as follows:

"'/usr/lib/libreoffice/program/soffice

Deb Gnome-shell

Deb Docky

Deb Google-chrome-stable

Deb Soffice

Deb Gnome-settings-daemon

Deb Gnome-terminal-server

If you do not follow the resource Id,xkill will change the mouse pointer to a special symbol, similar to "X". Just click on the window you want to kill and it will kill its communication with the server, and the program will be killed.

The code is as follows:

$ xkill

It should be noted that Xkill does not guarantee that its communication will be successfully killed/withdrawn. Most programs are killed when communication with the server is shut down. However, there are still a few parts that will continue to run.

The points to be noted are:

This tool can only be used when the X11 server is running, because this is part of the X11 tool.

Don't be confused when you kill a resource and it doesn't quit altogether.

This is not a substitute for kill.

Do I need to use Xkill on the Linux command line?

No, you don't have to run Xkill on the command line. You can set a shortcut key and use it to invoke Xkill.

Here's how to set up keyboard shortcuts in a typical Gnome3 desktop.

Go to setup-> select Keyboard. Click ' + ' and add a name and command. Click on the new entry and press the key combination you want. Mine is ctrl+alt+shift+x.

Gnome settings

Add shortcut keys

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.