Switch keyboard layout via CLI on Linux

When working in lab environments or on a client’s system, the keyboard layout may differ from what you are used to. For example, an English standard keyboard would start with the keys “QWERTY”, while in Germany it’s “QWERTZ”. Usually I can adapt quite quickly to one layout or the other (especially for coding, English often is the more convenient choice). When it does get annoying however is in environments where you are constantly switching: For example, when my host system uses a German keyboard layout, but the hosted VMs are English by default.

Luckily, you can easily change this with one simple command – extremely helpful for non-graphical environments. To set the keyboard layout to German, just type:

setxkbmap de

Now, “why should I ever want to switch to a German layout?” you might ask. Fair point, so if you want to see all available layout options to choose from the following command is for you:

localectl list-x11-keymap-layouts

On an out-of-the-box recent Kali Linux, this will return a list with 98 entries:

Enjoy the boost in productivity 🙂

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.