Linux : Change Default Console Keyboard Layout


Background

You are creating Linux VMs - whatever hypervisor you are using - and you are configuring your local keyboard layout. In my case, this will be Belgian (be-latin1). But, when you colleague from UK or US is connecting to the console for whatever reason, his password is always wrong. This is because he is using a different keyboard layout that the one used for VM creation. This is annoying and in most cases a waste of time. It does not happen when accessing the VM using SSH.

Let's localectl !

Your best friend for this case if localectl. To check the current status, issue this command :

# sudo localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: be-latin1
      X11 Layout: be

To list available mapping, you can use this command :

# sudo localectl list-keymaps
ANSI-dvorak
al
al-plisi
amiga-de
amiga-us
applkey
at
at-mac
at-nodeadkeys
at-sundeadkeys
atari-de
atari-se
atari-uk-falcon
atari-us
az
[...]

You can of course grep to find easily the mapping you are looking for. Let's say US English :

# sudo localectl list-keymaps | grep us
amiga-us
atari-us
ba-unicodeus
ba-us
br-latin1-us
br-nativo-us
cz-rus
cz-us-qwertz
ee-us
gh-hausa
hr-unicodeus
hr-us
is-latin1-us
it-us
lk-us
lt-us
mac-us
ml-us-intl
ml-us-mac
mt-us
ng-hausa
pt-nativo-us
si-us
sunt5-cz-us
sunt5-us-cz
tw-indigenous
us
us-acentos
us-alt-intl
us-altgr-intl
us-colemak
us-dvorak
us-dvorak-alt-intl
us-dvorak-classic
us-dvorak-intl
us-dvorak-l
us-dvorak-r
us-dvp
us-euro
us-hbs
us-intl
us-mac
us-olpc2
us-workman
us-workman-intl

It looks like the one we are looking for is us. To set the VC (Virtual Console) keyboard layout, we need to issue this command :

# sudo localectl set-keymap us

To confirm the change, issue the status command once more :

# sudo localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us
       X11 Model: pc105+inet
     X11 Options: terminate:ctrl_alt_bksp

Now, your UK and US colleagues are happy again ;)

This being said, you can always agree as a company policy that all Linux console are set to English US by default to avoid any further problem like this one.

Comments

What's hot ?

ShredOS : HDD degaussing with style

Mac OS X : Display images in-line with terminal