Change keyboard layout (English UK) on command line to English US

432,114

Solution 1

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.

Solution 2

Run this command:

sudo dpkg-reconfigure keyboard-configuration

This worked for me.

Solution 3

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

setxkbmap us

Solution 4

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

Solution 5

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.

Share:
432,114

Related videos on Youtube

Evelyn
Author by

Evelyn

Updated on September 18, 2022

Comments

  • Evelyn
    Evelyn over 1 year

    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.

    • terdon
      terdon about 10 years
      What exactly is the "Command Line" as opposed to the terminal? Do you mean a virtual console (tty)?
    • Evelyn
      Evelyn about 10 years
      CTRL + ALT + F2 brings up the Command Line
    • Evelyn
      Evelyn about 10 years
      lang=en_US.UTF-8
    • steeldriver
      steeldriver about 10 years
      @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?
    • terdon
      terdon about 10 years
      @steeldriver you are absolutely correct, I did not notice the Ctrl! Thanks, that makes this answerable!
    • Evelyn
      Evelyn about 10 years
      @steeldriver Thanks a lot! Your method worked for me.
    • terdon
      terdon about 10 years
      @user241411 really? You ran sudo dpkg-reconfigure console-setup? That only gave me options to change encoding and font, not the keyboard layout. I had to run sudo dpkg-reconfigure console-data to get the layout.
  • MadMike
    MadMike over 8 years
    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.
  • demaniak
    demaniak over 7 years
    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.
  • Olaf Dietsche
    Olaf Dietsche over 7 years
    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.
  • zzapper
    zzapper over 7 years
    This worked for me when using Chrome Remote Desktop to Mint even though the keyword layout is correct when logged in normally.
  • zeng_overflow
    zeng_overflow about 7 years
    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!
  • Alex
    Alex about 7 years
    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.
  • Augustin Riedinger
    Augustin Riedinger over 6 years
    I needed to reboot so that it takes effect, could you mention it in the answer? Cheers
  • AK_
    AK_ over 6 years
    2018 - working on Ubuntu 11.x
  • defiant
    defiant about 6 years
    @AugustinRiedinger I didn't have to reboot to get that into effect.
  • CatMan
    CatMan about 6 years
    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.
  • Lorenzo Lerate
    Lorenzo Lerate almost 6 years
    For Spanish use: loadkeys es
  • Miguel Ortiz
    Miguel Ortiz over 5 years
    No reboot is required.
  • zzapper
    zzapper about 5 years
    and me wanting to go the other way (mint) setxkbmap gb
  • hrvoj3e
    hrvoj3e almost 5 years
    setxkbmap working on arch (loadkeys not)
  • josephdpurcell
    josephdpurcell almost 5 years
    > sudo dpkg-reconfigure keyboard-configuration This worked for me.
  • Black
    Black over 4 years
    @Alex, Command not found
  • Dig
    Dig over 4 years
    Yes, running 16.04 (Thinkpad T430) and sudo dpkg-reconfigure keyboard-configuration worked a treat for me. Did not have to reboot just chose Generic 105 Int Keyboard and UK layout to recover my Keyboard after it had mysteriously change to US layout... Thanks
  • Timo
    Timo almost 4 years
    I am on LUbuntu 20?04. Does not work, do I have to reload the terminal or restart pc
  • Timo
    Timo almost 4 years
    Works on LUbuntu 20_04
  • Timo
    Timo almost 4 years
    Works not permanently
  • Zheng Qu
    Zheng Qu over 3 years
    I had to logout and back in to have it taking effect. [i3wm]
  • Jon Bentley
    Jon Bentley over 3 years
    Doesn't work in Ubuntu 20.04 server in freshly installed KVM machine. Applied UK layout, still have US layout.
  • Bobble
    Bobble over 3 years
    Note for UK keyboard use 'gb'
  • Joseph Garvin
    Joseph Garvin over 3 years
    If I have a custom kmap file how do I make it show up in this list? Or a custom xkb symbols file?
  • polendina
    polendina about 3 years
    for american-english (which is presumably the qwerty) sudo loadkeys us , os : ubuntu 10.04LTS
  • Derkades
    Derkades over 2 years
    It did require a reboot for be (Debian 11), so I guess if it doesn't work do try rebooting, even though it appears to work without a reboot for some.
  • Admin
    Admin almost 2 years
    This does not answer the OP. Locale and keyboard are quite unrelated.