In a nutshell, the localectl command allows you to control the system locale and keyboard layout settings. One of the main advantages of this command is that it is present in Linux distributions that use systemd. So, you can use it on almost any modern distribution.
The operation of the command is simple and may be used to query and change the system locale and keyboard layout settings.
Now, what can we do with localectl because the system locale controls the language settings of system services and of the UI before the user logs in, such as the display manager, as well as the default for users after login.
It is probably not as well known as other commands, but again, in remote support situations or configurations, it can be a great relief to have this command.
Using the localectl command on Linux
As I mentioned earlier, the
localectl command is present in distributions that use systemd. Therefore, you can find it by default in distributions such as Debian, Ubuntu and its derivatives, RHEL and its derivatives, and others such as Arch Linux and openSUSE.
If you run the command without any arguments, then you will get an output screen showing information about the system language, formats, and keyboard layout.
System Locale: LANG=en_GB.UTF-8
VC Keymap: n/a
X11 Layout: en
X11 Model: pc105
This same output can be obtained if you add the
In either case, as you can see, it is pretty useful to get information from it.
Another thing you can do is to display the command help via the terminal to give you a general idea of how it works. To achieve this, run.
You will get this output
localectl we can do two essential things. The first one is to change the locale of the system.
First, it shows the available options
You will get a sample output per screen to help you find your own. Remember that the size of the sample output will depend on the languages that have been downloaded to the system.
And to set a new one, just run the following command
localectl set-locale [locale]
localectl set-locale en_GB.UTF-8
You will probably have to exit the SSH session or restart the computer to apply the changes.
The second important thing you can do with the
localectl command is to change the keyboard layout.
It is convenient to, first, display the list of available layouts with the command
If you are using X11, then you can use the option to modify the keyboard with this argument.
Or display the different models
You can also show the available x11 layouts and variants
And to apply the changes you can run
localectl set-x11-keymap [keymap].
But you can also extend this command to add the model and layout
localectl set-x11-keymap LAYOUT [MODEL] [VARIANT]
This way, it is effortless to use the
localectl command to manage the system locale and the keyboard layout.
localectl command is a systemd tool to manage the keyboard layout, but also to change the system locale. This is essential to get the system right for the job.
I hope you liked this post, and you can share it with all your friends on social networks.