Change keyboard layout (English UK) on command line to English US
Andrew Mclaughlin
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.
87 Answers
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-configurationThe simplest way would indeed be as @steeldriver suggested to open a terminal and run this command:
sudo apt-get install console-commonThat 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-dataTested on 13.10, and taken from here.
6Run this command:
sudo dpkg-reconfigure keyboard-configurationThis worked for me.
7The above didn't work for me, but this did. From terminal enter the following command:
setxkbmap us 7 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 deTo make it permanent:
localectl set-keymap de 6 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.
1On 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 :
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc105"
XKBLAYOUT="de"
XKBVARIANT=""
XKBOPTIONS=""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
C
C.UTF-8
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE.utf8
de_LI.utf8
de_LU.utf8
en_AG
en_AG.utf8
...
POSIXIf 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-8More details (german source).