Changing TTY keyboard layout on a server?

346,196

Solution 1

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

Solution 2

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

However,

sudo dpkg-reconfigure keyboard-configuration

does work after reboot and also has more options.

More info here.

Solution 3

Try:

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

Solution 4

  • Set US layout: setxkbmap us
  • Set GB layout: setxkbmap gb

Solution 5

For me this did it

localectl set-keymap de-latin1

Share:
346,196
Mike
Author by

Mike

Updated on September 18, 2022

Comments

  • Mike
    Mike over 1 year

    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?

    • Dan Hibbert
      Dan Hibbert about 8 years
      Mike, would you consider changing the accepted answer? It looks like there is a much better answer now than the originally accepted answer.
  • JonnyJD
    JonnyJD almost 11 years
    Like that other answer mentions: This does not carry over a reboot. (tested in 12.04.1 LTS)
  • Tobias F. Meier
    Tobias F. Meier almost 11 years
    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
  • CMCDragonkai
    CMCDragonkai about 10 years
    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?
  • Clayton Dukes
    Clayton Dukes almost 10 years
    This is the correct answer, not the other one.
  • RCF
    RCF about 9 years
    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.
  • blkpws
    blkpws almost 9 years
    This commands only works for Ubuntu Desktop, not on Ubuntu Server.
  • jocull
    jocull over 7 years
    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.
  • lbo
    lbo over 7 years
    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.
  • SaAtomic
    SaAtomic almost 7 years
    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"
  • Andrea Turbiglio
    Andrea Turbiglio about 5 years
    doesn't work on my Ubuntu 18.04, keyboard layout in the console remains the same
  • RoBeaToZ
    RoBeaToZ over 4 years
    loadkeys de for german keyboard layout worked for me, thx!
  • Niko
    Niko over 3 years
    Worked for me in Ubuntu Server 20.04 with a Raspberry Pi 3B+ For some reason I had to be connected to the internet if I wanted the command to work properly and for the changes to stay active even after rebooting.
  • ATorras
    ATorras over 2 years
    It also works on Ubuntu 20 (focal)
  • user3804598
    user3804598 about 2 years
    loadkeys ru worked for russian, ctrl + shift to toggle between english and russian