Set up the key combination to ctrl-alt-backspace to kill x11. Linux is pretty stable but it is good to have a way to get out of the graphical environment and back to the login screen in case things go really wrong.
vim /etc/default/keyboard
look for the line
XKBOPTIONS=""
and change it to:
XKBOPTIONS="terminate:ctrl_alt_bksp"
or alternatively change it to:
# if you want to disable caps-lock and use it for
# entering international non ascii characters then use:
XKBOPTIONS="terminate:ctrl_alt_bksp,compose:caps"
# capslock compose key means that:
# ä = capslock -> a -> "
# è = capslock -> e -> '
It will take effect after the next restart of the computer. Alternatively you can run this command:
sudo udevadm trigger --subsystem-match=input --action=change
(see "man keyboard" for details)
You can print the settings that are actually in effect with the command setxkbmap (run it as the user that is logged into the graphical desktop). It is a good idea to print those with setxkbmap because there are many different places where keyboard settings can be configured. setxkbmap will show you the end result of all those different settings.
guido@x220 : ~ $ setxkbmap -query
rules: evdev
model: pc105
layout: us
options: terminate:ctrl_alt_bksp,compose:caps
You can as well run the following command to set this directly with setxkbmap:
setxkbmap -rules evdev -layout us -model pc105 -option terminate:ctrl_alt_bksp,compose:caps
Some desktop environments like unity and xfce allow you to configure the keyboard in a "keyboard preferences" GUI and that may unfortunately overwrite those system wide settings. In xfce (xfce4-keyboard-settings) you can tick "use system defaults" or overwrite but the unity keyboard config GUI will always overwrite the system settings. You can see what your keyboard looks like with the command:
gkbd-keyboard-display -l us