localectl
Control system locale and keyboard layout
TLDR
Show the current settings of the system locale and keyboard mapping
List available locales
Set a system locale variable
List available keymaps
Set the system keyboard mapping for the console and X11
SYNOPSIS
localectl [OPTIONS...] COMMAND [ARGUMENTS...]
PARAMETERS
--help
Show a short help message and exit.
--version
Show package version and exit.
--no-pager
Do not pipe output into a pager.
--json=MODE
Output in JSON format. Mode can be 'short' or 'pretty'.
status
Show the current system locale and keyboard settings configured for both the virtual console and X11.
set-locale LOCALE...
Set the system locale. This command updates the /etc/locale.conf file. Multiple locale assignments can be provided (e.g., LANG=en_US.UTF-8 LC_TIME=en_US.UTF-8).
list-locales
List all known locales that are supported by the system.
set-keymap MAP [TOGGLEMAP]
Set the virtual console (VC) keyboard map. This updates the KEYMAP variable in /etc/vconsole.conf.
list-keymaps
List all known virtual console keyboard maps.
set-x11-keymap LAYOUT [MODEL] [VARIANT] [OPTIONS]
Set the X11 keyboard map. This updates the X11_KEYMAP variables in /etc/vconsole.conf, which are used by Xorg.
list-x11-keymap-rules
List all known X11 keymap rules.
list-x11-keymap-models
List all known X11 keymap models.
list-x11-keymap-layouts
List all known X11 keymap layouts.
list-x11-keymap-variants [LAYOUT]
List all known X11 keymap variants, optionally filtered by a specific layout.
list-x11-keymap-options
List all known X11 keymap options.
DESCRIPTION
localectl is a powerful command-line utility designed to query and change the system-wide locale and keyboard layout settings on Linux systems. As an integral component of the
systemd initialization system, it offers a standardized and centralized approach to managing these critical configurations. Unlike older, more fragmented methods, localectl provides a unified interface for both the virtual console (VC) environment and the X11 graphical environment. It seamlessly manages the persistent storage of these settings by writing to and reading from the
/etc/locale.conf and /etc/vconsole.conf files, ensuring that your chosen language, character set, and keyboard mappings are consistently applied across reboots and different user sessions. This command simplifies the complex task of configuring how your system handles language, character encoding, number formatting, currency, and time, as well as mapping physical keyboard keys to their intended characters.
CAVEATS
Changing settings with localectl typically requires root privileges or PolicyKit authentication.
While localectl configures X11 keyboard maps, these changes may not take full effect until the display manager or X server is restarted.
The command relies heavily on systemd and may not be available or fully functional on non-systemd Linux distributions.
Locale changes made by set-locale only affect future processes and system services; existing processes might need to be restarted to pick up new locale settings.
CONFIGURATION FILES
localectl manages system-wide settings stored in two primary files: /etc/locale.conf for locale-related settings (e.g., LANG, LC_ALL) and /etc/vconsole.conf for virtual console keyboard mappings (KEYMAP) and font settings.
X11 KEYBOARD MAP INTEGRATION
When configuring X11 keyboard maps, localectl interacts with the underlying XKB (X Keyboard Extension) configuration system. It simplifies the selection of layouts, models, variants, and options that would otherwise be configured using lower-level tools like setxkbmap or by directly editing Xorg configuration files.
LOCALE CATEGORIES
The set-locale command allows setting various locale categories like LANG (general locale), LC_CTYPE (character classification and conversion), LC_NUMERIC (numeric formatting), LC_TIME (date and time formatting), LC_MONETARY (currency formatting), and LC_MESSAGES (message language). These categories dictate how the system behaves in terms of language-specific conventions.
HISTORY
localectl was introduced as a core component of the systemd project, aiming to consolidate and standardize system configuration tools. Its development focused on providing a consistent and persistent way to manage locale and keyboard settings across different boot stages and user environments, thereby replacing older, less integrated methods that varied across distributions. It rapidly became a standard utility in modern Linux systems adopting systemd, simplifying configuration for administrators.