Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Related to another question, is there a way to send SIGTERM to the currently focused local GUI window application with a keyboard shortcut? Like clicking the [X] button in most WMs or Ctrl-c for the command line. Not like Alt-SysRq-e since it kills every application :)

share|improve this question
A windows is something that has been displayed on your X server by some client application somewhere. It's like asking: "how to kill that firefox that is doing that HTTP request to my Web server" – Stéphane Chazelas May 28 '13 at 11:34
@StephaneChazelas that's not a correct analogy. You obviously own both the X server and the client application running on your machine. – phunehehe May 28 '13 at 11:41
As an example, one can get the PID using xprop, and then send signals to that PID. There may be better ways. – phunehehe May 28 '13 at 11:44
@phunehehe, that was not specified in the original question. There's no reason for that to be the case. X was designed as a network protocol especially to have clients on different machines as the server. The problem is not only for client vs server machine. There's the user issue as well, client applications of a same X server (even on the same machine) can run as different uids, and non-priviledged users can only kill their own processes. There's also clients that server as proxies to other clients (like ssh -X) which you'd have to consider. – Stéphane Chazelas May 28 '13 at 11:47
@phunehehe, the _NET_WM_PID property is voluntarily specified by the client application. The application can lie, or not specify it, or it can be irrelevant if it's from another machine, or that particular process have died but the X connection being shared by another process. Use at your own risk. – Stéphane Chazelas May 28 '13 at 11:54

From the comments and from the linked question, I suspect that you want something like xkill. It kills an application (that is, all windows of the application).

There is a question on askubuntu about killing the active application. There is another question with an answer showing how to create a custom keyboard shortcut. You can combine the two to get a single keyboard shortcut that kills the active application. Of course, the bit about creating a keyboard shortcut depends on your window manager.

Note from man xkill:

This command does not provide any warranty that the application whose connection to the X server is closed will abort nicely, or even abort at all. All this command does is to close the connection to the X server. Many existing applications do indeed abort when their connection to the X server is closed, but some can choose to continue.

Working solution: Assign a new shortcut (as described above) pointing to /usr/local/bin/xkillthis, then run this:

echo 'xkill -id `xprop -root _NET_ACTIVE_WINDOW | cut -d\# -f2`' | sudo tee /usr/local/bin/xkillthis
sudo chmod a+x /usr/local/bin/xkillthis
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.