Home / Alt manpages / xkill(1)

  • xkill(1)
  • User command
  • linux

Stop a Frozen X Window Safely with xkill

You will use xkill to close an unresponsive X11 application's connection, without guessing its process ID. The normal workflow takes about two minutes once you have a usable display and a window to target. This is a blunt recovery tool: it asks the X server to close a client connection, and the application may lose unsaved work.

Prerequisites and the safety boundary

This guide covers the xkill 1.0.6 supplied by Debian package x11-utils. You need an X11 session, permission to connect to that display, and a pointer. You do not normally need sudo. Running the command as root does not automatically grant access to another user's X display and can create confusing authentication problems.

Warning

Xkill does not send a polite request to the application. Closing the X connection can make a program abort, lose unsaved data, or behave differently if it can continue without X. Save work first if the application still responds. Do not use -all in routine recovery: it is designed to kill every client with a top-level window on the screen.

1. Confirm the installed command

First check that the command is present and record its version. This does not contact the X server or kill anything.

command -v xkill
xkill -version

On this system, the second command reports xkill 1.0.6. If the command is missing, install the distribution's x11-utils package through your normal package-management process. Do not substitute a similarly named process-killing command: xkill targets an X resource, not a PID.

2. Start interactive window selection

Run xkill with no resource identifier. It changes the pointer to a selection cursor. Move it over the window belonging to the stuck application and click the configured button.

xkill

By default, xkill uses the first button in the pointer map, normally the left button. The X server then closes the connection belonging to the selected non-root window. The window should disappear, or the application should terminate shortly afterwards.

Checkpoint

Select only the window you have positively identified. Window-manager decorations can make a target look like one application while the client window underneath belongs to another. If you have changed your mind before clicking, cancel the selection using the method provided by your desktop or window manager, or move away and use the normal keyboard interrupt for the foreground command.

3. Use a different pointer button when needed

If the default button is inconvenient, select a numbered button explicitly. The number is the pointer button number understood by X, not a mouse-button name.

xkill -button 3

To allow any pointer button to select the window, use the documented word any.

xkill -button any

Use one of these forms only when you understand your pointer mapping. A wrong button can make selection feel broken, which is easy to misread as an X11 failure.

4. Target a known X resource

Interactive selection is usually safest, but scripts and careful diagnosis sometimes need a known X identifier. Use xwininfo to inspect a window, then pass the reported identifier to xkill. This inspection is read-only.

xwininfo
xkill -id 0x01234567

Replace 0x01234567 with the resource identifier you actually obtained. Do not copy this example value. The -id option tells xkill which resource's creator to abort; it is not a process ID and it is not interchangeable with a value from ps.

For a display other than the current one, specify the X display name on both inspection and termination commands as appropriate:

xkill -display DISPLAY_NAME -id 0x01234567

Replace DISPLAY_NAME with a real value such as :0 only when that is the display you are authorised to use. A display connection failure means xkill did not perform the requested action. Check echo "$DISPLAY" and your X authentication rather than adding sudo at random.

5. Understand what success means

xkill closes the selected client's connection to the X server. It does not guarantee a tidy application shutdown, and it does not guarantee that the process exits. The manpage specifically warns that some applications can continue after their X connection closes.

After selection, verify the visible result and check the application itself. If the window remains, wait briefly, then look for the application's own recovery behaviour. If you need to determine whether a process is still running, use ordinary process-inspection tools rather than assuming that the disappearance of a window proves termination.

6. Avoid the dangerous and specialised options

The -all option asks you to select the root window with each currently defined button and then kills all clients with top-level windows. It is highly discouraged by the local manpage. Treat it as a deliberate session-disruption action, not a faster version of ordinary selection. There is no xkill undo for clients that have already lost their connection.

The -frame option changes how xkill finds top-level client windows by ignoring the usual window-manager conventions and looking at direct children of the root. Use it only when normal selection cannot identify the intended client and you understand the window hierarchy. It can change which client is treated as the target.

7. Recover when the target was wrong

There is no restoration command for an X connection closed by xkill. Restart the affected application and recover its files using that application's own recovery feature. If you accidentally closed a window from a larger session, reopen the required programs manually and check for unsaved work before continuing.

If xkill itself is waiting for a selection, do not click an unknown window. Cancel the foreground command using your terminal's normal interrupt, then start again when you can identify the target. If xkill reports that it cannot open the display, resolve the display or authorisation issue first; elevated privileges are not a general fix.

Done means

  • You confirmed the installed xkill version without contacting the X server.
  • You identified the stuck window before selecting it.
  • You used interactive selection or a verified X resource ID, not a guessed PID.
  • You avoided -all unless deliberately accepting session-wide disruption.
  • You checked whether the application exited and recovered any unsaved work it could restore.