How to Configure System Locale and Keyboard Layouts in Ubuntu Using localectl

In Ubuntu and modern Linux system administration, managing system localization\u2014such as language character encoding (UTF-8), regional date/time conventions, numeric formatting, virtual console keymaps, and graphical X11/Wayland keyboard models\u2014traditionally required manually editing disparate configuration files like /etc/default/locale and /etc/default/keyboard. To unify localization management and synchronize configuration changes atomically between early boot consoles and graphical desktop environments, systemd provides the centralized command-line utility localectl.

Understanding How localectl Interacts with systemd-localed

The localectl command communicates via D-Bus with the systemd-localed.service background daemon:

  • System Locale Settings: Governs regional language formats, collation order, monetary formats, and UTF-8 encoding variables written to /etc/locale.conf and /etc/default/locale.
  • Console Keymaps: Defines the keyboard translation tables active in early boot text consoles (TTY1\u2013TTY6) prior to graphical display manager initialization.
  • X11/Wayland Keyboard Maps: Dictates keyboard layout rules, models, variants, and options (such as switching Caps Lock to Ctrl or toggling multi-language inputs) written to /etc/default/keyboard and /etc/X11/xorg.conf.d/00-keyboard.conf.

Querying Current Localization Settings with localectl

To inspect active localization and keyboard parameters across your Ubuntu system:

localectl status

The command outputs a comprehensive status report:

   System Locale: LANG=en_GB.UTF-8
                  LANGUAGE=en_GB:en
       VC Keymap: uk
      X11 Layout: gb
       X11 Model: pc105
     X11 Options: terminate:ctrl_alt_bksp

Notice the segregation between VC Keymap (virtual console) and X11 Layout (graphical display server).

Listing Available Locales and Keymaps

Before configuring a new language or keymap, verify what profiles are installed and supported on your machine:

To list installed locales:

localectl list-locales

To list available virtual console keymaps:

localectl list-keymaps | grep -i "uk"

To list supported X11 layout codes (e.g., gb, us, de, fr):

localectl list-x11-keymap-layouts

Configuring the Primary System Locale

If you need to change your primary operating system locale (for example, switching from US English to British English):

sudo localectl set-locale LANG=en_GB.UTF-8 LANGUAGE=en_GB:en

You can also define fine-grained localization categories independently:

  • LC_TIME: Controls 24-hour vs 12-hour clock representations and date formatting.
  • LC_MONETARY: Controls currency symbols and decimal separators.
  • LC_NUMERIC: Formats thousands separators and number representations.

For example, to enforce British English date and time formatting while retaining US English system messaging:

sudo localectl set-locale LANG=en_US.UTF-8 LC_TIME=en_GB.UTF-8

Configuring Virtual Console Keymaps

To change the keyboard mapping active in Linux text virtual terminals (TTYs):

sudo localectl set-keymap uk

By default, when you execute set-keymap, systemd-localed automatically converts the console mapping and synchronizes the corresponding X11 layout to match.

Configuring Graphical X11 and Wayland Keyboard Layouts

To configure keyboard behavior for desktop environments (GNOME, KDE Plasma, XFCE) and display servers:

sudo localectl set-x11-keymap gb pc105 "" terminate:ctrl_alt_bksp

The parameters in order are:

  1. layout: gb (British English layout).
  2. model: pc105 (standard 105-key generic PC keyboard).
  3. variant: "" (standard variant; or specify dvorak, mac, etc.).
  4. options: terminate:ctrl_alt_bksp (enables emergency X server restart shortcut).

To configure multi-language toggling (e.g., allowing Alt + Shift to toggle between English and German layouts):

sudo localectl set-x11-keymap gb,de pc105 "" grp:alt_shift_toggle

Verifying System Configuration Files

To confirm that systemd-localed has written changes to permanent system storage:

cat /etc/default/locale
cat /etc/default/keyboard

The files reflect the parameters defined via localectl, ensuring consistent keyboard input and character rendering across both local terminal sessions and graphical desktops.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.