Linux: change keyboard layout on the fly

How can you change the keyboard layout (to QWERTY from QWERTZ) on the fly from a Linux shell?

I found this similar question, but the answer was to edit a config file, which is not so easy when you're using a Live CD.


Solution 1:

setxkbmap

Solution 2:

kbdconfig or loadkeys

That's how we used to do it. I don't know if they're still supported; I'll check next time I've got Knoppix running.

Solution 3:

I'm not aware of any tool that changes keymap on-the-fly, but in at least debian it is possible to edit /etc/default/console-setup with your preferred map, and make the system reflect those changes by issuing /etc/init.d/hal restart.

Solution 4:

On recent systems, if you have root privileges, you can use the following:

localectl set-keymap en_GB

for the virtual console keyboard, and

localectl set-x11-keymap en_GB

for the X11 layout.