Change Keyboard Layout with localectl

Use localectl set-x11-keymap to set the system-wide keyboard layout and localectl set-keymap for the text console.

LinuxlocalectllocalesystemdkeyboardMedium risk
Run `sudo localectl set-x11-keymap de` (substitute your layout code) to change the default keyboard layout.

01Command

Command
$ sudo localectl set-x11-keymap de

02What it does

`localectl set-keymap de` changes the layout in the text consoles (Ctrl+Alt+F3), while `set-x11-keymap de` changes the graphical session default that applies at the login screen. List valid codes with `localectl list-x11-keymap-layouts`. On GNOME and KDE, Settings has its own input-source switcher which takes precedence for your user session, so localectl mainly fixes the login screen and console layout.

03Risk

RiskMedium risk
Requirementssystemd-based distro (Ubuntu, Debian, Fedora, Arch). GNOME and KDE have their own layout switchers in Settings that override this for the session.
!Warning: If you mistype a layout code the command fails safely, but on systems where it applies, a wrong console keymap makes passwords typed at the console appear different from what you expect.

04Undo

Undo
$ sudo localectl set-x11-keymap us

05Sources

  • Linux console/Keyboard configuration - ArchWiki
    Arch Linux Wiki · technical · 2026-09-17
    Evidence: Describes how localectl set-keymap configures the virtual console keymap while set-x11-keymap configures the graphical X11 keymap.
  • localectl(1) - Linux manual page
    Ubuntu Manpages · technical · 2026-09-17
    Evidence: localectl set-x11-keymap sets the system default X11 keyboard layout, model, variant and options; set-locale changes the system locale.

Last verified: 2026-09-18 · Category: System & Settings

06Related solutions