How to Use the xkill command to kill Linux processes/unresponsive programs
How do we kill a resource/process in Linux? Obviously, we will find the resource pid and then use the kill command.
To better understand this, we can find the PID of a resource (such as terminal:
$ ps -A | grep -i terminal
6228?00:00:00 gnome-terminal
In the above output, '1234568' is the pid of the process (gnome-terminal). Use the following command to kill the process.
$ kill 6228
The kill command sends a signal to the pid process.
Another method is to use the pkill command, which can kill a process based on the process name or other attributes. We can also kill a process named terminal in this way:
$ pkill terminal
Note: The pkill command is followed by a process name of no more than 15 characters.
Pkill seems easier to use, because you don't need to find the pid of the process. But if you want to better control the system, there is nothing to beat 'kill '. You can use the kill command to better examine the processes you want to kill.
We have an article covering the details of kill, pkill, and killall commands.
For those running X Server, there is another tool called xkill that can kill the process from X Window without passing its name or pid.
The xkill Tool forces X server to close the connection with its customer program. The result is that X resource closes the customer program. Xkill is an easy-to-use tool in the X11 tool set to kill useless windows.
For example, if you use the-display option to connect to the specified X Server with the display number when running multiple X servers at the same time, use-all (not recommended) kill all top-level windows on the screen and frame (-frame) parameters.
To list all client programs, you can run:
$ xlsclients
Sample output
' '/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 the resource id is not followed, xkill will convert the mouse pointer into a special symbol, similar to "X ". You only need to click in the window you want to kill, it will kill its communication with the server, and this program will be killed.
$ xkill
Use xkill to kill a process
It should be noted that xkill does not guarantee that its communication will be successfully killed/exited. Most programs will be killed after the communication with the server is closed. However, a small number of instances continue to run.
Note the following points:
- This tool can only be used when the X11 server is running, because it is part of the X11 tool.
- Do not get confused when you kill a resource and it is not completely exited.
- This is not a substitute for kill.
Do I need to use xkill in the linux Command Line?
No, you do not have to run xkill in the command line. You can set a shortcut key and use it to call xkill.
The following describes how to set keyboard shortcuts in a typical gnome3 desktop.
Go to Settings> select the keyboard. Click '+' and add a name and command. Click the new entry and press the key combination you want. My options are Ctrl + Alt + Shift + x.
Gnome settings
Add shortcuts
The next time you want to kill an X resource, you only need to use the combination key (Ctrl + Alt + Shift + x). You can see that your mouse is changed to x. Click the x resource to be killed.
Via: http://www.tecmint.com/kill-processes-unresponsive-programs-in-ubuntu/
Author: Avishek Kumar Translator: geekpi Proofreader: wxy
This article was originally translated by LCTT and launched with the Linux honor in China
This article permanently updates the link address: