Login screen keyboard layout stays QWERTY on Debian/Ubuntu
Published 18 July 2026
- date
- env
- linux Ubuntu 24.04 LTS (arm64, Parallels VM on Apple Silicon) — applies to Debian 12/13 and all Ubuntu flavours macos N/A
- tags
Symptom
You log into your desktop and everything is fine: the keyboard is AZERTY (or whatever
layout you configured in GNOME Settings → Keyboard). But at the login screen itself,
the keyboard is still QWERTY. Typing a password containing a, q, z, w, m or any
digit produces the wrong characters, and there is no obvious way to switch layout before
authenticating.
Typical trigger: a fresh Debian/Ubuntu install where the installer defaulted to us
(very common in virtualised installs — Parallels, VMware, UTM, cloud images — because the
installer never sees the physical keyboard).
Checking the current state confirms it:
cat /etc/default/keyboardXKBMODEL="pc105"XKBLAYOUT="us"XKBVARIANT=""XKBOPTIONS=""BACKSPACE="guess"Root cause
There are two independent keyboard configurations on the machine:
| Scope | Where it lives | Who reads it |
|---|---|---|
| Your session | dconf / GNOME Settings, per user | Your desktop session only |
| System-wide | /etc/default/keyboard | The greeter, TTYs, initramfs, LUKS prompt |
The display manager greeter (GDM, LightDM, SDDM) does not run as your user. GDM runs
as the dedicated gdm system user with its own dconf profile, so it has no idea what you
configured in GNOME Settings. It falls back to the system-wide layout — which is still us.
The second half of the problem is distribution-specific and is the reason this how-to is
split from its systemd counterpart: on Debian and Ubuntu, localectl set-x11-keymap — the
command every generic Linux tutorial recommends — is disabled on purpose:
Setting X11 and console keymaps is not supported in Debian.Debian delegates keyboard configuration to the console-setup / keyboard-configuration
packages, whose single source of truth is /etc/default/keyboard. systemd-localed is
patched out of that role to avoid two subsystems fighting over the same setting. So on these
distributions you edit the file, then apply it.
Diagnosis
Confirm that the system-wide layout is the culprit and not the session:
localectl statuscat /etc/default/keyboardIf localectl status shows X11 Layout: us (or n/a) while your session behaves as AZERTY,
the split described above is confirmed.
Identify your display manager, because the verification step differs:
cat /etc/X11/default-display-managersystemctl status display-manager --no-pager | head -3Find the exact layout/variant codes available on the system:
grep -E "^\s+(fr|be)\s" /usr/share/X11/xkb/rules/base.lstawk '/! variant/,0' /usr/share/X11/xkb/rules/base.lst | grep " fr:"The second command is the one that matters for Apple keyboards: it lists the mac variant
of the fr layout, which maps the </>, @, # and dead keys the way an Apple French
keyboard is physically engraved.
Solution
Prerequisites and warnings
- You need
sudorights. - Do not use
localectl set-x11-keymaphere — it will fail with the “not supported in Debian” message. That command belongs to the other how-to. - Changing this file also changes the layout of the TTY consoles and the initramfs/LUKS passphrase prompt. That is usually what you want, but be aware of it if your disk encryption passphrase was typed with a QWERTY layout in mind.
- Have a way back in (a second admin account, or an SSH session from another machine) in case you mistype the layout code and lock yourself out of the greeter.
Steps
-
Edit the system-wide keyboard configuration.
Terminal window sudo nano /etc/default/keyboardSet the four XKB fields. For a French AZERTY Apple keyboard:
XKBMODEL="pc105"XKBLAYOUT="fr"XKBVARIANT="mac"XKBOPTIONS=""BACKSPACE="guess"Common alternatives:
Keyboard XKBLAYOUTXKBVARIANTFrench AZERTY (PC) fr(empty) French AZERTY (Apple) frmacFrench AZERTY (new AFNOR norm) frafnorBelgian AZERTY be(empty) US International usintl -
Regenerate the configuration.
Terminal window sudo dpkg-reconfigure keyboard-configurationAn interactive menu appears. It is pre-filled with the values you just wrote, so simply confirm each screen. If you prefer to skip the dialog entirely, the next command alone is often enough:
Terminal window sudo setupcon -
Apply to the running console and to the initramfs.
Terminal window sudo setupcon --savesudo update-initramfs -uupdate-initramfsis only required if your root filesystem is encrypted and you want the passphrase prompt to use the new layout too. Skip it otherwise. -
Reboot.
Terminal window sudo rebootA full reboot is the reliable way to make the greeter pick up the change. Restarting the display manager alone (
sudo systemctl restart display-manager) works too, but it kills every running session without warning.
Verify
At the login screen, type your password into the username field first (where it is visible) to check the characters, then clear it and log in normally.
Once logged in:
localectl statuscat /etc/default/keyboardsetxkbmap -querylocalectl status should now report:
X11 Layout: fr X11 Model: pc105 X11 Variant: macsetxkbmap -query only works under X11/XWayland; under a pure Wayland session use:
gsettings get org.gnome.desktop.input-sources sourcesIf the greeter is still QWERTY while /etc/default/keyboard is correct, the problem has
moved to the display manager itself — see Alternatives below.
Rollback
Restore the previous values and re-apply:
sudo nano /etc/default/keyboardsudo setupcon --savesudo rebootIf you are locked out of the greeter because of a wrong layout, log in from a TTY
(Ctrl+Alt+F3) — but note the TTY now uses the same broken layout. The safest recovery is
SSH from another machine, or a root shell via GRUB Advanced options → recovery mode.
Alternatives
The greeter still ignores the setting (LightDM). LightDM does not always inherit
console-setup. Force it with a greeter setup script:
sudo tee /etc/lightdm/lightdm.conf.d/50-keyboard.conf > /dev/null <<'EOF'[Seat:*]display-setup-script=/usr/bin/setxkbmap fr macEOFsudo systemctl restart lightdmThe greeter still ignores the setting (GDM under Wayland). GDM reads the X11 keymap even
in a Wayland session, via xkbcommon. If /etc/default/keyboard is not honoured, create the
Xorg fragment by hand — this is the file localectl would have written on other distributions:
sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf > /dev/null <<'EOF'Section "InputClass" Identifier "system-keyboard" MatchIsKeyboard "on" Option "XkbLayout" "fr" Option "XkbModel" "pc105" Option "XkbVariant" "mac"EndSectionEOFsudo rebootOffering a layout picker instead of a fixed layout. Listing several comma-separated layouts makes a selector appear in the greeter’s top bar:
XKBLAYOUT="fr,us"XKBVARIANT="mac,"Apple keyboard oddities. If the mac variant still misplaces a few keys, test the plain
fr layout for comparison. The mac variant is calibrated for built-in MacBook keyboards;
an external Apple keyboard connected to a PC or a VM sometimes matches plain fr better.
Under a VM in particular, the hypervisor already translates scancodes, so the guest may not
need the mac variant at all. Test both before settling.
Sources
- Ubuntu manpage:
keyboard(5)— format of/etc/default/keyboard - Debian Wiki — Keyboard configuration
- delphix-platform PR #552 — documents
localectl set-x11-keymapbeing unsupported on Debian/Ubuntu 24.04 - GNOME System Administration Guide — Display multiple keyboard layouts on the login screen