Debian: change the keyboard layout from the console

I’ve installed a new test system to play around a little bit (a Debian Squeeze install). Since I was too lazy to install it from scratch and I’m using VMWare anyway, I thought I’d just download a pre-installed virtual machine.

Now this virtual machine had a US keyboard configured and I’m using a German keyboard. After googling for how to change the keyboard layout from the console, I found a few hints:

dpkg-reconfigure console-data

Unfortunately the package console-data is not installed on my system.

Then I found the following:

dpkg-reconfigure keyboard-configuration

This package is installed and you can choose a keyboard layout. Great !

After saving, I pressed “Z” and got a “Y” on the console. So still having a US keyboard configured.

Since keyboard-configuration modifies the file /etc/default/keyboard, I checked this file:

# cat /etc/default/keyboard
# Check /usr/share/doc/keyboard-configuration/README.Debian for
# documentation on what to do after having modified this file.
# The following variables describe your keyboard and can have the same
# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options
# in /etc/X11/xorg.conf.

XKBMODEL=”pc105″
XKBLAYOUT=”de”
XKBVARIANT=”nodeadkeys”
XKBOPTIONS=””

# If you don’t want to use the XKB layout on the console, you can
# specify an alternative keymap. Make sure it will be accessible
# before /usr is mounted.
# KMAP=/etc/console-setup/defkeymap.kmap.gz

Everything looks fine… But the hint in the beginning of the file might be pointing to the solution. So let’s check this README.Debian file:

# cat /usr/share/doc/keyboard-configuration/README.Debian
After modifying /etc/default/keyboard, you can apply the changes to the linux console by running setupcon. If X is configured to use that file too, then the changes will become visible to X only if

udevadm trigger –subsystem-match=input –action=change

There is the solution:

#setupcon

And the keyboard layout is German !!

12 thoughts on “Debian: change the keyboard layout from the console

  1. Thank you. this helped me a lot. I was stumped as to why the dpkg-reconfigure keyboard-configuration wasn’t taking any effect in the console.

  2. Hi. Thank you. Your guide helped me. But I found my setupcon was looking into /usr/etc/default/keyboard and not into /etc/default/keyboard. So I created the dir and copyed th file. Then setupcon worked.

  3. Thanks but didn’t work for me while running Debian 7 off a USB keydrive.

    “setupcon” says “We are not on the console, the console is left unconfigured.”, and am still stuck with the US keyboard layout.

  4. Great thanks 🙂

    But I had to run
    # sudo service keyboard-setup restart
    Instead of “setupcon” for the changes to have any effect

Leave a Reply

Your email address will not be published. Required fields are marked *