Use the xkill command to kill unresponsive processes in Linux systems


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):


Copy code

The code is as follows:

$ ps -A | grep -i terminal
6228 ? 00:00:00 gnome-terminal

In the above output, ‘6288’ is the PID of the Gnome terminal. Use the following command to kill the process.


Copy code

The code is as follows:

$ kill 6228

The Kill Command sends a signal to the PID process.

Another way is that we can use the pkill command, which can kill a process based on its name or other properties. Similarly, if we want to kill a process called terminal, we can do this:


Copy code

The code is as follows:

$ pkill terminal

Note: the length of the process name after the pkill command is no more than 15 characters

Pkill seems easier to use because you don’t have to find the PID of the process. But if you want better control of the system, nothing can beat ‘kill’. Using the kill command can better examine the process you want to kill.

For those running X server, there is another tool called xkill that can kill a process from X window without passing its name or PID.

The xkill tool forces the X server to close the connection with its client. As a result, the X resource closes the client. Xkill is a very easy tool to kill useless windows in X11 tool set.

It supports options such as using the – display option followed by the display number to connect to the specified X server when running multiple x servers at the same time, using – all (not recommended) to kill all top-level windows on the screen, and the frame (- frame) parameter.

To list all clients, you can run:


Copy code

The code is as follows:

$ xlsclients

Sample output


Copy code

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 the resource ID is not followed, xkill will turn the mouse pointer into a special symbol, similar to “X”. Just click on the window you want to kill, it will kill its communication with the server, and the program will be killed.


Copy code

The code is as follows:

$ xkill

2015723183730327.png (814×547)

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 few will continue to operate.

The points to be pointed out are:

    This tool can only be used when X11 server is running, because it is part of X11 tool.
    Don’t be confused when you kill a resource and it doesn’t quit completely.
    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 call xkill.

Here is how to set keyboard shortcuts in a typical Gnome 3 desktop.

Enter settings – > select keyboard. Click ‘+’ and add a name and command. Click on the new entry and press the key combination you want. My is Ctrl + Alt + Shift + X.
2015723183750202.png (792×499)

Gnome settings
2015723183828705.png (792×499)

Add shortcut keys