Home / Alt manpages / systemd-localed.service(8)

  • systemd-localed.service(8)
  • Admin command
  • linux

Set Linux Locale and Keyboard Defaults with systemd-localed

systemd-localed is the service behind localectl, the tool you reach for when a fresh install boots into the wrong keyboard layout or locale. This guide takes you from inspecting the current settings to changing the system locale, console keymap and X11 layout, each with a reversible check. Allow about 10 minutes. Reading the current state is safe; changing it needs administrator privileges and can affect new logins, display managers and text consoles.

1. Confirm the local systemd version

This guide follows the systemd 255 interface installed on the reference machine. Check yours before relying on an example, because distributions can package different releases and different locale or keymap data.

$ localectl --no-pager --version
systemd 255 (255.4-1ubuntu8.17)

The package revision is distribution-specific. What matters for the commands below is the systemd major version and the command's successful exit status.

2. Inspect the current settings

systemd-localed.service can change the system locale, the console keymap and the default X11 keyboard mapping. It is normally activated on request and can exit when unused, so do not treat its process lifetime as a setting that needs manual management.

$ localectl --no-pager status
System Locale: LANG=en_US.UTF-8
    VC Keymap: (unset)
   X11 Layout: us
    X11 Model: pc105

Your output will differ. The --no-pager option keeps a short result in the terminal and avoids a distracting interactive pager; it does not alter the configuration.

Checkpoint

Save or copy the current output before making a change. It gives you the values needed to undo the example later.

3. Check that the target value exists

Do not guess a locale or keymap name. Ask the installed system for its choices:

$ localectl --no-pager list-locales
C.UTF-8
en_US.UTF-8

$ localectl --no-pager list-keymaps
Failed to read list of keymaps: No such file or directory
  • The locale list is host-specific. Use what your own machine offers, not a value copied from a tutorial.
  • A list-keymaps failure usually means missing keymap data, not that a guessed layout is valid. Install or enable the distribution's keyboard-data package through its normal package-management process before using set-keymap; this guide does not assume a package name.

For X11 settings, enumerate layouts, models, variants and options separately:

$ localectl --no-pager list-x11-keymap-layouts | sed -n '1,12p'
$ localectl --no-pager list-x11-keymap-models | sed -n '1,12p'
$ localectl --no-pager list-x11-keymap-variants us

These only query the local installation. An empty result or an error means you should investigate the keyboard data on that host, not copy a value from another distribution.

4. Change the system locale

Choose one locale from list-locales. A single argument to set-locale sets LANG; assignments let you set a more specific category such as messages:

$ sudo localectl set-locale LANG=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
$ localectl --no-pager status
System Locale: LANG=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8

The command updates the system-wide locale configuration, normally /etc/locale.conf. It affects services and users that inherit the system environment, but it does not rewrite every user's shell configuration and it does not retroactively change an already-running process. Start a new login or service to observe the inherited value.

Safety warning

Do not use LC_ALL in locale.conf. The file supports settings such as LANG, LANGUAGE and individual LC_* categories, but LC_ALL is explicitly not valid there.

To undo the example, restore the exact values recorded in step 2. For an ordinary default, set LANG to a locale from the list and remove any category overrides with the corresponding localectl set-locale VARIABLE= assignment, if your installed command supports it. Verify with localectl status, and do not edit the file by hand while also making changes through localectl.

5. Set the console keymap and X11 layout separately

Use set-keymap for the virtual console mapping. Unless --no-convert is used, localectl also tries to convert it to a close X11 mapping. Only use a name confirmed by list-keymaps:

$ sudo localectl set-keymap us
$ localectl --no-pager status

That example changes system state, so use your saved values to reverse it. For example, if the earlier status showed no console keymap, the recovery command is:

$ sudo localectl set-keymap ''

If your distribution rejects an empty value, restore the previous named keymap instead. Verify after either command; do not repeatedly retry a missing keymap, fix the missing keyboard data first.

For a graphical default, use set-x11-keymap. The layout is required; model, variant and options are optional and must match the X keyboard data installed on the host.

$ sudo localectl set-x11-keymap us pc105
$ localectl --no-pager status
   X11 Layout: us
    X11 Model: pc105

The command may also convert the X11 mapping to a console mapping. If that is not wanted, add --no-convert:

$ sudo localectl --no-convert set-x11-keymap us pc105

Use conversion deliberately. A console mapping and an X11 mapping are related but not identical data, and the closest conversion may not preserve every variant or option you need.

6. Account for boot-time and service effects

localectl writes the system defaults through systemd-localed; it does not rebuild the initrd automatically. If the setting must apply during early boot, check how your distribution builds initrds and rebuild it with that distribution's documented tool during a maintenance window.

Changing a locale or keyboard default can alter messages, parsing assumptions and login-screen input for later processes. Before changing a remote host, keep an existing administrative session open and test a second login. If the result is wrong, use that session to restore the recorded values.

Do not restart systemd-localed.service as a routine step. It is the D-Bus service that performs the operation; localectl is the supported client. Inspect its state only when diagnosing a failed request:

$ systemctl status systemd-localed.service --no-pager

A static or on-demand service can be healthy without being continuously active. Investigate the error from localectl first, then inspect the unit and journal if the request still fails.

Done means

  • You confirmed the installed systemd and localectl version.
  • You recorded the original output from localectl status.
  • You selected locale, console keymap and X11 values from the host's own lists.
  • You know which examples need sudo and which only read state.
  • You verified every change with localectl --no-pager status.
  • You have a recovery value for any changed setting and know that initrd updates are separate.