I am using Ubuntu 12.04. The keyboard layout is English US everywhere except for the Command Line where it works in English UK. Terminal also has English US. How do I change the default keyboard layout in Command Line to English US?

Also, I think it might be worth noting here, that when I had installed Ubuntu (dual boot with Windows 8. 1), I had initially set the language as English UK, but later changed it to English US from the system settings.

  • 4
    What exactly is the "Command Line" as opposed to the terminal? Do you mean a virtual console (tty)? – terdon Mar 16 '14 at 4:22
  • CTRL + ALT + F2 brings up the Command Line – Evelyn Mar 16 '14 at 12:00
  • lang=en_US.UTF-8 – Evelyn Mar 16 '14 at 22:06
  • 1
    @terdon I think you second guessed yourself, Ctrl+Alt+F2 should indeed be a virtual terminal (the 'Run Dialog' is plain Alt+F2). I'm not sure if console-setup is installed by default, but perhaps the OP should try sudo dpkg-reconfigure console-setup? – steeldriver Mar 17 '14 at 2:03
  • @steeldriver you are absolutely correct, I did not notice the Ctrl! Thanks, that makes this answerable! – terdon Mar 17 '14 at 2:07

Update 2017-04-13: This seems to have changed in recent Ubuntu versions and running sudo apt-get install console-common will try to remove other packages. So, for recent Ubuntu versions, use this instead (Tested in 17.04):

sudo dpkg-reconfigure keyboard-configuration

The simplest way would indeed be as @steeldriver suggested to open a terminal and run this command:

sudo apt-get install console-common

That will install the console-common package and in the process allow you to chose your console layout. If that is already installed, use this to bring up the same wizard and set the layout:

sudo dpkg-reconfigure console-data

Tested on 13.10, and taken from here.

  • 12
    Using Ubutnu 14.04 I was able to set the keyboard on a text-console. But after a reboot it would be reset to the previous settings. Only after issuing a sudo dpkg-reconfigure keyboard-configurationI was able to set it permanently. – MadMike Oct 5 '15 at 20:59
  • Seems like a bit of kludge to do something so seemingly simple - but hey, it worked on a Raspberry PI (running raspbian), so cool, thanks. – demaniak Sep 20 '16 at 12:57
  • 5
    This doesn't work anymore with 16.04. Installing console-common wants to remove packages cryptsetup, plymouth, lightdm, and some others. dpkg-reconfigure keyboard-configuration does work however. – Olaf Dietsche Oct 3 '16 at 15:43
  • 1
    Goddamn it. After I ran this command and reboot, it stuck at the purple blank screen. Turns out this command also removed plymouth and unity. @OlafDietsche is right! – zeng_overflow Apr 4 '17 at 17:05
  • > sudo dpkg-reconfigure keyboard-configuration This worked for me. – josephdpurcell Aug 30 at 0:22

Run this command:

sudo dpkg-reconfigure keyboard-configuration

This worked for me.

  • I needed to reboot so that it takes effect, could you mention it in the answer? Cheers – Augustin Riedinger Jan 4 '18 at 16:50
  • @AugustinRiedinger I didn't have to reboot to get that into effect. – defiant Apr 5 '18 at 8:45
  • 1
    No reboot is required. – Miguel Ortiz Nov 20 '18 at 14:02

The above didn't work for me, but this did. From terminal enter the following command:

setxkbmap us
  • This worked for me when using Chrome Remote Desktop to Mint even though the keyword layout is correct when logged in normally. – zzapper Jan 11 '17 at 17:42
  • 2018 - working on Ubuntu 11.x – AK_ Jan 21 '18 at 19:47
  • and me wanting to go the other way (mint) setxkbmap gb – zzapper May 7 at 16:17
  • setxkbmap working on arch (loadkeys not) – hrvoj3e Jun 5 at 11:19

I have a console only (without X) Linux running inside a VirtualBox. Needed to change layout from US keyboard to a German one. This worked for me:

loadkeys de

To make it permanent:

localectl set-keymap de
  • 7
    Thanks to you I found the solution for me, running my server in VNC. Your command changes it temporarily. To make it permanent I used localectl set-keymap de. – Alex Apr 11 '17 at 14:26
  • Thanks. This works on a fresh server 16.04 install out of the box. The above setxkbmap solution requires to install some X11 utils, which IMHO did not seem the right thing to do on a server. – CatMan May 9 '18 at 17:38
  • For Spanish use: loadkeys es – Lorenzo Lerate Aug 4 '18 at 13:02
  • @Alex, Command not found – Black Oct 4 at 11:37

I'm running 14.04 LTS with a standard US keyboard. My problem was that I had relied on the installer to choose US-Intl for me and it caused "dead keys" and improper formation of the " and ' keys (as well as others I don't know about, I'm sure).

After a lot of frustration and trial and error, I ran the "sudo apt-get install console-common" suggestion and it fixed my problem, but only while I was logged in.

When I logged out, restarted the server and back in, it failed.

It only took hold permanently when I executed the "sudo dpkg-reconfigure keyboard-configuration" command and specified the generic US keyboard.

"setxkbmap" did not work for me.

It seems that (I don't KNOW) setxkbmap is obsolete in 14.04 LTS.

  • setxkbmap gb worked for me just now in 16.04.01 LTS – Mike Sep 30 '16 at 10:49

On Ubuntu/Debian you have /etc/default/keyboard config file which actually manages the keyboard layout on your distro. When you boot your system the /etc/default/keyboard file is read by setup scripts along with other config files. If you look at the output of /etc/default/keyboard file you can see my keybord layout is set to german de :


# Consult the keyboard(5) manual page.


It is not good idea (like other config files) to directly change the attributes of /etc/default/keyboard file.

To change the layout or model of your keyboard always use following command:

sudo dpkg-reconfigure keyboard-configuration

Additional Information.

You should probably also change your locale!

Use locale -a to show all possible languages:

$ locale -a

If your locale is not in the above list, then you have to generate it:

$ sudo locale-gen fr_FR.UTF-8
Generating locales...
  fr_FR.UTF-8... done
Generation complete.

The default settings are stored in /etc/default/locale:

You can either manually configure it, or use the tool:

update-locale LANG=de_DE.UTF-8

More details (german source).

protected by Community Apr 1 '18 at 18:37

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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