68

Ctrl+Alt+ can usually be set to restart X, however I can't find the option to allow this (it is disabled by default).

I have looked in System->Preferences->Keyboard and System->Preferences->Keyboard Shortcuts but I can't find an option to enable it.

Where can I change this setting?

Jorge Castro
  • 71,754
dv3500ea
  • 37,204

9 Answers9

68

This was tested on 13.10+, type the following on the terminal:

sudo dpkg-reconfigure keyboard-configuration

enter image description here

You will see the keyboard configuration. Press ENTER 5 times to skip all keyboard related options except for the Kill X part. When you get to the Kill X option which looks like this:

enter image description here

Select YES and press enter. Wait a bit while everything configures and after that you should have the ability to CTRL+ALT+BCKSPC right on the current session. After saving any work you have pending, try it yourself.

Perfect to solve any visual issues or annoying apps.

Thank you @david-c it also looks like this works:

Sudo Edit the /etc/default/keyboard file and add the line XKBPTIONS="terminate:ctrl_alt_bksp" to it, so it looks something like this:

enter image description here

Luis Alvarado
  • 211,503
34

For Unity (13.04 to 17.04):

You want: System->Preferences->Keyboard

Then click the Layouts tab, the Options button, and expand Key sequence to kill the X server, before finally selecting the checkbox.

Screenshot

To enable it via the command line install dontzap Install dontzap

sudo apt-get install dontzap

And in a terminal

sudo dontzap --enable

To disable the shortcut:

sudo dontzap --disable
Pablo Bianchi
  • 15,657
8128
  • 28,740
  • 1
    The dontzap package is not included in Ubuntu 11.10. – Stefan Lasiewski Nov 19 '11 at 16:59
  • For me, it appears to be disabled in System->Preferences->Keyboard but in fact it's still active, destructive and "out there". dontzap doesn't seem to be "active" (as in actively developed) either, and it seems counterintuitive to have to install it in order to disable this key-combo. Any other ways to really and fully disable it? – nutty about natty Jul 09 '13 at 09:20
  • ps: I think this is a bug. Some time ago, I enabled it cuz I thought it was kinda cool - not knowing that it was a one-way-street (no disabling functionality built-in). pps: I'm on precise. – nutty about natty Jul 09 '13 at 09:23
  • The System->Preferences->Keyboard works also for Ubuntu 14.04 with MATE desktop. – sdaau Dec 06 '17 at 22:23
  • Where exactly is the option to enable this shortcut on 16.04? Cannot find it. – Nickolai Leschov Jun 13 '19 at 05:15
22

You can also use dconf-editor. This option will make the setting persistent across sessions.

sudo apt-get install dconf-editor

After starting the dconf-editor, navigate to org >> gnome >> desktop >> input-sources

Add the options that you need in xkb-options. The option strings are surrounded by single quotes and separated by commas. Be careful not to delete the brackets on the ends.

To enable ctrl+alt+backspace to kill the X-session, add 'terminate:ctrl_alt_bksp'

You can use this method to enter most of the traditional xkb options that are no longer available in System Settings >> Text Entry. The exceptions are the settings for switching the keyboard layouts, which currently do not work because of a bug.

For a list of the options and the syntax, use man 7 xkeyboard-config in a terminal.

To run the commands equivalent to using dconf-editor from a terminal, you use

gsettings set org.gnome.desktop.input-sources xkb-options "['terminate:ctrl_alt_bksp']"

Note the single quotes around the value, the square brackets around that, the double quotes around the whole thing. In other words, just like in dconf-editor.

Note that this will delete your other settings in xkb-options, if you have any.

You can get the existing settings with

gsettings get org.gnome.desktop.input-sources xkb-options

If you don't change these values very often, it might be simplest to combine existing settings with the new one by hand and the run gsettings set.

It can also be done all at once on the command line. I've put it in a short script here to make it easier to read.

#!/bin/bash
options=$(echo $(gsettings get org.gnome.desktop.input-sources xkb-options)|sed 's/]//g')", 'terminate:ctrl_alt_bksp']"
gsettings set org.gnome.desktop.input-sources xkb-options "$options"

The 2nd line gets the current values and concatenates the terminate... option. The sed command strips the right square bracket from the current values.

Note that while the argument string to the gsettings get command in the terminal needs double quotes around the value

"['val', 'val2']"

the argument string when run in a script should not have the double quotes.

['val', 'val2']
chaskes
  • 15,246
20

For 13.10 and newer:

If you are looking for a solution which is independent of Gnome/KDE/Fluxbox or any Desktop Environment or Window Manager, try the following X Window System command. I need this because my Unity desktop is not loading (but X works fine), therefore there is no logout button.

From https://wiki.ubuntu.com/X/Config/DontZap#Using_the_command_line

Using the command line

You can type the following command to enable Zapping immediately.

setxkbmap -option terminate:ctrl_alt_bksp

If you're happy with the new behaviour you can add that command to your ~/.xinitrc in order to make the change permanent.

Also, according to the Ubuntu 10.04 LTS (Lucid Lynx), this has replaced the old DontZap feature from older versions of the X Window System.

In addition, the Ctrl+Alt+Backspace option is now configured as an X keymap (XKB) option, replacing the X server "DontZap" option and allowing per-user configuration of this setting.

This is explained further in the Xorg X11R7.5 Release Notes which, among other details, say:

Users who wish to have this functionality available by default may
enable it via the XKB configuration option “terminate:ctrl_alt_bksp”.

  • 2
    @Jorge Castro @Stefan Lasiewski Thanks for your advice. One-time option with setxkbmap works, but adding it to ~/.xinitrc on 13.10 doesn't do anything. Probably, ~/.xinitrc isn't used anymore on the latest Ubuntu? How do I enable Zapping permanently, then? – Nickolai Leschov Dec 23 '13 at 12:41
  • @Nickolai Leschov. I had the same problem. In 13.10, try the method using the dconf-editor described in the answer by chaskes. – Fern Moss Dec 26 '13 at 21:38
8

It was changed to Alt+Prt Scr+k.

I can't remember exactly when it was but it was supposed to stop accidental usage.

The idea being those who know they need it will be able to find the new key combination easily enough.

And I think someone at the time suggested it would be easier to remember as it is alternative screen kill. I am not sure that is the case.

The functionality is still there but under a different key combination.

8128
  • 28,740
  • 3
    Just to mention "Alt + Prt Scr" is marked on most keyboards as "SysRq" (System request) to help you easily remember this. – 8128 Oct 31 '10 at 21:20
  • 1
    Thanks for your answer. As it happens, this doesn't work on my laptop. Both prt sc and sys rq need fn to be pressed and cause gnome-screenshot to open; many times if I hold it down for too long. – dv3500ea Oct 31 '10 at 21:44
  • 15
    -1. Alt + PrtScr + k or (SysRq + k) is a magic SysRq key combination that kills all processes on the current virtual console. It can be used to kill the X server, however it isn't the replacement for Ctrl + Alt + Bksp. In Ubuntu 9.04 Ctrl + Alt + Bksp got disabled (not removed) by default and could be enabled by setting a X server flag ('DontZap'), and as of Ubuntu 9.10 it's like described by fluteflute. – htorque Oct 31 '10 at 21:58
  • 5
    Found the release notes. The Ubuntu answer to this question is on this page https://wiki.ubuntu.com/LucidLynx/ReleaseNotes about half way down. – Richard Holloway Oct 31 '10 at 22:17
8

(This is for Gnome Ubuntu, but I suppose it is the same for Unity --- please someone confirm this).

You should install gnome-tweak-tool (if not installed already) and run it. You will find the option you are looking for under "Typing":

g-t-t typing

If you feel more confortable with dconf-editor (or you do not want to install gnome-tweak-tool), you can open dconf-editor, navigate to org.gnome.desktop.input-sources, and then add the word "terminate:ctrl_alt_bksp" to the xkb-options property.

dconf-editor xkb properties

Note that the other properties in the list will be probably different for your keyboard.

Rmano
  • 31,947
  • 1
    Thank you....Gnome Tweak does work in Unity, however, it is very hard to see as the white background that should be behind the right box with the list and menu options is transparent so it shows whatever is behind it(setting a white background would be a workaround but it is still usable....) The Dconf editor works as well and might be the better choice for readability but is a bit harder to use..... – TrailRider May 07 '14 at 23:02
2

For Ubuntu 20.04 with Gnome 3 desktop, with the Gnome Tweaks app:

  1. Open Gnome Tweaks
  2. Navigate to Keyboard & Mouse tab
  3. Find and click the button: Additional layout options
  4. In the list popping up, locate and expand the item labelled Key sequence to kill the X server
  5. Check the checkbox for the desired key combination
    • probably it's gonna be Ctrl+Alt++Backspace
Levente
  • 3,961
2

You can still get back Ctrl+ Alt+Backspace shortcut to restart X by opening a terminal and copy paste the following:

sudo dpkg-reconfigure keyboard-configuration
Seth
  • 58,122
Mr_Chmod
  • 172
-1

This didn't appear to change anything at all and didn't activate the key combination.

In Kubuntu (KDE, plasma-framework version 5.23 on Kubuntu 16.04 Xenial) I found the option under K > System Settings > Input Devices > Keyboard > Advanced. Open the menu item "key sequence to kill X server" and check the only option "Ctrl + Alt + Backspace", apply.

Using strace I can see that this adds a line to /home/$USER/.config/kxkbrc which reads: Options=terminate:ctrl_alt_bksp.

The setxkbmap rule did work though and places a line reading terminate:ctrl_alt_bksp = +terminate(ctrl_alt_bksp) in the /usr/share/X11/xkb/rules/evdev file.

pbhj
  • 3,231