Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How I change keyboard layouts from the command-line? For example, I want to switch from English to Hebrew. I'm able to do it from lightdm with the little icon in the corner of my screen.

share|improve this question

4 Answers 4

up vote 14 down vote accepted

From terminal

English to Hebrew and vise versa with Alt + Shift

setxkbmap -option grp:alt_shift_toggle us,il

You can see all locale alias with this command

cat /etc/locale.alias

More info about setxkbmap in manual

man setxkbmap
share|improve this answer

You can find all the different keymaps in the following location: /usr/share/keymaps/i386/ or /usr/share/kbd/keymaps/i386/

To change the keyboard layout (e.g. to Spanish) in the Linux command line, type the following command:

loadkeys es

For X:

setxkbmap es

To make these changes system wide, assuming you’re using Ubuntu, you can use the following:

sudo dpkg-reconfigure console-setup
share|improve this answer
    
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works. –  Eyal Oct 30 '12 at 13:21
    
I added a command in the answer, was this what you were looking for? –  Dr_Bunsen Oct 30 '12 at 13:25
    
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'? –  Eyal Oct 30 '12 at 13:27
    
yep I will, and no thanks. Just mark as solved so everyone knows. –  Dr_Bunsen Oct 30 '12 at 13:28

Ubuntu 13.10 or Later

This works better then setxkbmap with Gnome/Unity keyboard layout indicator.

gsettings set org.gnome.desktop.input-sources current 0

0 is the layout index (0 default or top layout). Layouts indexed starting from 0.

For easy use, create an alias.

share|improve this answer
setxkbmap us,il -option "lv3:ralt_alt,grp:alt_shift_toggle"

this command enable you toggle between English and Hebrew only through by right alt+shift and rescue you from left alt+shift.

share|improve this answer
    
Why is this answer downvoted? Is anything wrong with it? –  Adam Ryczkowski Apr 7 at 10:42
    
really for what ??!! i test it myself and worked for me :( –  ansar313 Jun 15 at 9:27
    
I'll upvote it then, for a good measure :-) –  Adam Ryczkowski Jun 15 at 9:31
    
wooow. thanks a lot. :-) –  ansar313 Jun 15 at 9:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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