I need to change layout of keyboard while working in console in Linux. I need to setup English layout as default for console. How to do it?

  • What distro are you using? – emzero Mar 24 '12 at 23:31
  • Ubuntu, logged under root – J.Olufsen Mar 24 '12 at 23:37
  • 1
    "loadkeys us" worked! How to make it default layout? – J.Olufsen Mar 24 '12 at 23:42
up vote 28 down vote accepted

To change the system-wide keyboard layout, run

sudo dpkg-reconfigure keyboard-configuration

or edit the XKBLAYOUT line in /etc/default/keyboard.

To change your keyboard layout fast, just install setxkbmap with:

sudo apt-get install x11-xkb-utils

After this you can always change the keyboard layout with:

setxkbmap us

To do this automatically every time, extend your .bashrc with:

echo "setxkbmap us" >> ~/.bashrc

Now, open a new console and the US keyboard layout is activated. Don't worry if the small keyboard layout icon in the Ubuntu panel does not change.

  • This does not really change the default keyboard layout but is a sort of hack to reset the keyboard layout to another one everytime you open a new console (while it is only necessary to reset after reboot). For a permanent solution, it is possible to set it directly, for example in /etc/default/keyboard like suggested by other answers. – baptx Aug 16 at 15:27

another way, but I understand it wont last for next boot:

sudo loadkeys /usr/share/keymaps/i386/qwerty/us.kmap.gz

check /usr/share/keymaps/i386/ for you keyboard layout and keymaps to what suits you better

  • Put it in /etc/profile.d/bashrc – B K Mar 25 '12 at 1:01
  • @BK, may be at /etc/rc.local to not require sudo? – Aquarius Power Dec 26 '17 at 18:48

the very funny could be to switch back.. possible solution is, to make bash script (named w/ symbols of target language. for instance, англ). 2nd trick is, to type "setxkbmap us; setxkbmap ru" then it's possible to use bash history to return main layout to console.

  • 1
    Can you please clarify (1) what you’re saying, and  (2) how it answers the question? – Scott Mar 6 at 20:29
  • well, you switched console in russian language. how would you like to switch it back to english 777 actually, i didn't answer main question, i just added some tricks to avoid possible problems. For example, you work w/o gui & switched console to russian, so you cannot type any command. :) – Evgeney Knyazhev Mar 6 at 22:06

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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