Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 25 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 locations:


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
for redhat users, following are the valuable pieces: /usr/share/X11/xkb/symbols/ and setxkbmap es – Peter Butkovic Nov 18 '15 at 11:35
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

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

Your Answer


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.