What it does
localectl shows and changes the machine’s default locale (language/region settings) and keyboard configuration. It can manage both the Linux virtual console keymap and the X11 keyboard layout.
How it works (mechanical)
- Talks to
systemd-localed(via D-Bus). - Writes locale settings to
/etc/locale.conf. - Writes console keymap settings to
/etc/vconsole.conf. - X11 keyboard settings may be recorded and/or applied depending on distro and display stack.
- Changes typically take effect for new sessions; some may require re-login or restart of relevant services.
10 Practical Examples
# 1) Show current locale + keymap status localectl status
# 2) List installed/available locales localectl list-locales
# 3) Set the system default locale (common) sudo localectl set-locale LANG=en_US.UTF-8
# 4) Set multiple locale categories sudo localectl set-locale LANG=en_US.UTF-8 LC_TIME=en_GB.UTF-8
# 5) View the active locale from libc’s perspective (sanity check) locale
# 6) List console keymaps (may be long; pipe to less) localectl list-keymaps | less
# 7) Set console keymap (TTY / virtual console) sudo localectl set-keymap us
# 8) Set X11 keymap (for classic Xorg desktops) sudo localectl set-x11-keymap us
# 9) Set X11 keymap with model + variant + options (example) sudo localectl set-x11-keymap us pc105 "" "ctrl:nocaps"
# 10) Inspect the config files localectl manages cat /etc/locale.conf cat /etc/vconsole.conf
Notes & Gotchas
- Requires sudo to change settings.
- Some desktop environments manage keyboard layouts themselves; X11 changes may be overridden by DE settings.
- Wayland sessions often use compositor/DE settings;
set-x11-keymapmay not affect Wayland. - If you set a locale that isn’t generated/installed, apps may warn or fall back. Generate locales via distro tools.
- Locale and time settings matter for AD/Kerberos and certificates indirectly (time), and for scripts/parsers (locale).
Historical Context
Before systemd, admins typically edited /etc/sysconfig/i18n, /etc/default/locale,
or symlinked /etc/localtime depending on distro, and managed keymaps via loadkeys or
Xorg configuration. localectl centralized these knobs under systemd.
Modern Equivalent
On systemd systems, localectl is the standard interface. Desktop environments may provide their own UI for language and keyboard settings; under the hood, they may still interact with systemd or write config files directly.
Related Commands
- timedatectl — system time, timezone, and NTP
- hostnamectl — hostname and machine metadata
- locale — show current locale environment variables
- loadkeys — load a console keymap
- setxkbmap — set X11 keyboard layout directly