I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

How to change the keyboard layout using the terminal

Hello, friends. In this post, you will learn how to change the keyboard layout using the terminal. Although simple, it is quite useful for configuration and scripting.

Using a graphical interface, it is easy to change the keyboard layout on Linux. Simply access the desktop environment options and look for a hardware or input method section related to the keyboard.

From there you can not only change the configuration but also other things related to the keyboard, but what if it is a server, or we are only accessing via SSH? Well, you have to use the terminal.

Let’s start.

How to change the keyboard layout using the terminal

To make this change, you can do it using several methods. First, you can do it by running this command.

sudo dpkg-reconfigure keyboard-configuration

By running the command, you will be able to choose a specific keyboard model and then the language and variant.

Configuring the keyboard
Configuring the keyboard

Furthermore, you can configure the function of the AltGr key and Compose Key

Change the keyboard layout
Change the keyboard layout

At the end, the set changes will be written.

Another option for changing the keyboard layout

Although the previous option is simple and easy to use, it is intended for Debian-based systems such as Ubuntu and its derivatives. A more universal solution is to do it with the localectl command.

To set the new distribution, just run

sudo localectl set-keymap us

Replace us with the language you want to change the keyboard layout to.

If you would like to check the changes run

localectl status

And the value you have to pay attention to is X11 Layout.

Bonus: Another universal method

But there is also a last method that I would like to show you and that is editing the file /etc/default/keyboard.

sudo vi /etc/default/keyboard

And the value that you have to modify is XKBLAYOUT for the acronym of the required language.

Save the changes and you are done.


In this post, you learned a simple process such as changing the keyboard layout using the terminal. This process although easy will help us in more than one occasion.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook