LinuxCommandLibrary

xkill

Forcefully terminate a graphical program (X client)

TLDR

Display a cursor to kill a window when pressing the left mouse button (press any other mouse button to cancel)

$ xkill
copy

Display a cursor to select a window to kill by pressing any mouse button
$ xkill -button any
copy

Kill a window with a specific ID (use xwininfo to get info about windows)
$ xkill -id [id]
copy

SYNOPSIS

xkill [-id resource] [-frame]

PARAMETERS

-id resource
    Specifies the X resource ID (e.g., window ID) of the client to kill directly, bypassing the interactive click mode. This allows for non-interactive termination, useful for scripting.

-frame
    When clicking, targets the window manager's frame around the application window, rather than just the application's client window itself. This can be useful for applications that are difficult to target directly because their visible area is primarily handled by the window manager.

DESCRIPTION

The xkill command is an X Window System utility designed to forcefully terminate misbehaving or unresponsive graphical applications (X clients). When executed without arguments, xkill changes the mouse cursor, typically to a skull and crossbones or a similar distinctive icon. The user then clicks on the window of the application they wish to terminate.

Upon clicking, xkill sends a "KillClient" request to the X server, which in turn closes the connection of the selected application to the X server, effectively shutting it down. This method is a last resort as it does not allow the application to save its state or perform a graceful shutdown. It's particularly useful when an application freezes and cannot be closed through normal means. It only works on X applications, not on console processes or services.

CAVEATS

Using xkill is a destructive action; unsaved work in the targeted application will be lost. Be cautious when the cursor changes, as clicking the wrong window can terminate critical components of your desktop environment (e.g., your panel, file manager, or even the entire desktop shell). It terminates the X client's connection, which may not always kill the underlying process cleanly, potentially leaving a zombie process or other orphaned resources. It's a tool of last resort and should be used carefully.

INTERACTIVE VS. NON-INTERACTIVE USE

By default, xkill operates in an interactive mode where the cursor changes, prompting the user to click on the target window. The -id option allows for non-interactive use, where a specific X resource ID is provided as an argument, making it suitable for scripting or automated tasks.

CANCELLING XKILL

If you launch xkill and decide not to terminate any application, you can usually cancel the operation by pressing the Escape key, or by clicking a mouse button other than the primary (left) button (e.g., right-click or middle-click).

HISTORY

xkill has been a fundamental part of the X Window System utilities since its early days (X11R1 in 1987). Its simple yet effective mechanism for terminating unresponsive X clients made it an indispensable tool for users and administrators alike. Its core functionality has remained largely unchanged, reflecting the enduring design principles of the X server's client management.

SEE ALSO

kill(1), pkill(1), killall(1), xprop(1), xwininfo(1), wmctrl(1)

Copied to clipboard