I use 12.04 Server in command line mode (no X installed), and I would like to change the keyboard layout. How can I do this?

  • Mike, would you consider changing the accepted answer? It looks like there is a much better answer now than the originally accepted answer. – Azendale Apr 24 '16 at 18:29

Please try the following command:

sudo dpkg-reconfigure console-data

If it says you don't have the package, then install console-data with:

sudo apt-get install console-data

More about Locale Configuration: LocaleConf - Community Help Wiki

| improve this answer | |
  • 19
    Like that other answer mentions: This does not carry over a reboot. (tested in 12.04.1 LTS) – JonnyJD Aug 1 '13 at 20:11
  • 1
    A hint for people who want to change their keyboard layout during console install: Edit /etc/apt/sources.list and add 'universe' to the listed URL. Otherwise it can't find consol-data – Tobias F. Meier Aug 19 '13 at 17:46

After trying sudo dpkg-reconfigure console-data, I found out that it doesn't work after a reboot.


sudo dpkg-reconfigure keyboard-configuration

does work after reboot and also has more options.

More info here.

| improve this answer | |
  • 2
    How do I find out what kind of keyboard I have? It's the Windows 8 Surface pro one. What's the US standard one? – CMCDragonkai Apr 9 '14 at 2:16
  • 24
    This is the correct answer, not the other one. – Clayton Dukes Jun 19 '14 at 15:55
  • Older Ubuntu releases, such as Lucid Lynx (10.04), don't have the keyboard-configuration package. Göran's link has the correct answer for these: sudo dpkg-reconfigure console-setup If your cursor keys don't work as expected in the ncurses UI, try those on the numeric keypad. – lbo Oct 9 '16 at 8:43


loadkeys es (Spanish)
loadkeys pt (Portuguese)
loadkeys br (Brazilian Portuguese)
loadkeys ch (Swiss German)

| improve this answer | |
  • 2
    doesn't work on my Ubuntu 18.04, keyboard layout in the console remains the same – Andrea Turbiglio Mar 21 '19 at 14:42
  • 1
    loadkeys de for german keyboard layout worked for me, thx! – RoBeaToZ Nov 25 '19 at 20:05
  • Set US layout: setxkbmap us
  • Set GB layout: setxkbmap gb
| improve this answer | |
  • 9
    This commands only works for Ubuntu Desktop, not on Ubuntu Server. – blkpws Aug 20 '15 at 16:44

I just had this issue on a console mode only VM.

The solution in my case was editing /etc/default/keyboard and changing the


line (a german VM) to


to work with my US keyboard and then rebooting.

| improve this answer | |
  • I believe this only works with a GUI. Also - the reboot is not really required, you can also set the variable in the current terminal by simply overwriting it. XKBLAYOUT="us" – SaAtomic Jun 9 '17 at 8:28

Using Ubuntu 13.10 Server as a Virtual Machine in VirtualBox, this worked for me:

(no GUI, only command-line mode)

Default keyboard layout was French, 'AZERTY'

loadkeys us (English, was not 'en' for me, as some docs state)

Note that you will likely have to run the command as sudo loadkeys us.

| improve this answer | |
  • You might want to edit your last line and use sudo instead of root, since root is not the recommended method for commands needing administrator priviledges. – RCF May 9 '15 at 3:34
  • 1
    I could not get loadkeys us to work, even with sudo. It was saying that the file "us" couldn't be found. This on my Raspberry Pi. – jocull Sep 25 '16 at 17:48

For me this did it

localectl set-keymap de-latin1

| improve this answer | |

I succeeded today configuring this on my Raspberry Pi 3 via:

  • generating the required locale locale-gen de_DE.UTF-8
  • calling loadkeys de
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.