Introduction
In current Linux systems, language, regional format and keyboard distribution settings are managed through the systemd subsystem, and commandlocalectlis the most direct command line interface to inspect and modify these parameters. Unlike traditional configuration files like/etc/locale.confor/etc/vconsole.conf, localectlallows immediate and persistent changes without the need to manually edit the files, reducing the risk of syntax errors. This post explains step by step how to uselocalectlto see the current configuration, set up a new location, change the keyboard distribution and ensure that the settings survive at rebeginnings.
What is localectl
localectlis part of the set of systems tools and is responsible for consulting and modifying the environment variables related to internationalization (i18n) and the console keyboard (vconsole). The command reads information from the files/etc/locale.confand/etc/vconsole.confbut you can also write on them safely. In addition, it shows the system locale, the console locale, the keyboard map (keymap) and the character set (font) that is being used.
See the current configuration
To get a summary of the regional configuration and the keyboard, just run:
localectl status
The output includes lines such as:
- System Locale: LANG = es _ ES.TF-8
- VC Keymap: en
- X11 Layout: es
These values indicate the location used by the system services, the keyboard map of the virtual console and the distribution of X11 (if a graphic environment is being used).
Change the system location
If you need to change the language and regional format (e.g. move from Spanish to United States English), use the subcommandset-locale. For example:
sudo localectl set-locale LANG=en_US.UTF-8
This command updates the file/etc/locale.confwith the new variable and, optionally, recharges the environment for the processes that read it later. You can set multiple variables at once, such as:
sudo localectl set-locale LANG=en_US.UTF-8 LC_TIME=en_US.UTF-8
After applying the change, check again withlocalectl statusto confirm that the location has been updated.
Modify the distribution of the console keyboard
The keyboard distribution on the virtual console is controlled by the keymap. To change it, use:
sudo localectl set-keymap es
or, if you prefer a different design:
sudo localectl set-keymap us
The command writes the new configuration in/etc/vconsole.conf. In systems with a graphic environment, you may also want to adjust the X11 layout:
sudo localectl set-x11-keymap es
The latter adjusts the Xorg configuration file (usually low)/etc/X11/xorg.conf.d/) or usessetxkbmapaccording to distribution.
Apply changes persistently
An advantage oflocalectlis that the changes are written directly in the configuration files, so they survive rebeginnings without further steps. However, some desktop environments can overwrite these settings through their own regional adjustment demons. In such cases, it is recommended that:
- Check that service
systemd-localedis active (systemctl status systemd-localed). - Check the documentation of the desktop environment (GNOME, KDE, etc.) to ensure that there are no conflicts.
- Reset service
systemd-localedafter making changes (sudo systemctl restart systemd-localed) for new values to be spread to active sessions.
Common problem solution
If after runninglocalectl set-localethe output oflocalecontinue to show the above value, consider:
- Check that the location you are trying to generate is really installed in the system (
locale -a | grep en_US.UTF-8). If it's missing, génello withsudo locale-gen en_US.UTF-8orsudo dpkg-reconfigure localesin Debian / Ubuntu. - Make sure there are no overwritten environment variables in shell start files (
~/.bashrc,~/.profile). - Review the log of
systemd-localedwithjournalctl -u systemd-localedto detect error messages.
As for the keyboard, if the distribution does not change on the console, check that the specified keymap exists in/usr/share/kbd/keymaps/and that the file/etc/vconsole.confcontains the right line, for exampleKEYMAP=es.
Conclusion
The commandlocalectlis a powerful and simple tool to manage the internationalization and keyboard configuration in Linux systems based on systemd. Your ability to read and write directly into the configuration files makes it the preferred option compared to the manual editing of/etc/locale.confand/etc/vconsole.conf. Whether you need to change the language of the system, adapt the keyboard to your region or solve locale problems,localectloffers a unified and secure interface that ensures that the settings persist after restarts and are available in both the console and in graphic environments.


