How to Kill Linux Processes/Unresponsive Applications Using ‘xkill’ Command

How do we kill a resource/process in Linux? Obviously we find the PID of the resource and then pass the PID to the kill command.

Speaking more accurately, we can find PID of a resource (say terminal) as:

$ ps -A | grep -i terminal

6228 ?        00:00:00 gnome-terminal

In the above output, the number ‘6228‘ is the PID of process (gnome-terminal), use the kill command to kill the process as shown below.

$ kill 6228

The kill command sends a signal to a process, whose PID is passed along with the command.

Alternatively, we can use pkill command, which kills a process based upon name and other attributes of a process. To kill a process say whose name is terminal, we need to execute:

$ pkill terminal

Note: The process name length in pkill is limited to 15 characters.

pkill seems more handy as you can kill a process without have to find out its PID. But if you want to have a better control on your system nothing beats ‘kill‘ command. Using kill you will have better insight of what process you are killing.

We have already covered a detailed guide on kill, pkill and killall commands.

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

xkill utility forces X server to close communications to its client which results into killing of client by its X resource. xkill which is a part of X11 utilities is very handy in killing unnecessary windows.

It support options like connect to specific X Server (-display displayname) using display number when multiple X Servers are running on a host simultaneously and kill all the client (-all, not recommended) with top-level windows on the screen as well as take frame (-frame) into account.

To get a list of all the clients you may 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 no resource identifier is passed with id, xkill turns the mouse Pointer into special Symbol, similar to ‘X‘. Just click on the window you want to kill and this will kill its communication with server or say the program gets killed.

$ xkill
Xkill Command
Kill Process Using xkill

It is important to notice that xkill do not guarantee that closing its communication will kill/abort it successfully. Most of the application will get killed when it’s communication to server is closed. However a few may still be running.

Points Needed to be mentioned here:

  1. This tool works only when X11 server is running, as xkill is a part of X11 utility.
  2. Don’t confuse with Closing and killing a resource. While killing a resource you may expect it not to exit cleanly.
  3. This is not a replacement of kill utility.
Do I need to go to Linux command line to invoke xkill?

No, you don’t need to fire xkill from Linux Command Line. You may set a keyboard shortcut and call xkill just by punching same key combination.

Here is how to setup a keyboard shortcut on a typical gnome3 Desktop Environment.

Go to Settings –> Select Keyboard, click on ‘+’ and add name and command. Click on the new entry and press the key you want to use as shortcut key combination. I did Ctrl+Alt+Shift+x.

Gnome Settings
Gnome Settings
Add Shortcut Key
Add Shortcut Key

The next time you want to kill a X resource just call the key combination (Ctrl+Alt+Shift+x), and you will notice your mouse pointer changed into x. Click on x resource you want to kill and all done!

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.