17

I changed my Keyboard Layout from Swedish to English, but now my password doesn’t work and I can’t login. I need a way to change the keyboard layout at the login screen without having access to the keyboard or a way to enter the password using characters not available on the keyboard itself.

7 Answers7

30
  • Press Ctrl+Alt+F1 to switch console mode. Type your username and press Enter and also now type your password.

  • Next type sudo dpkg-reconfigure keyboard-configuration and hit Enter type your password again and follow screen instruction.

As usual, it will prompt you for the model of keyboard (what the keyboard is), and then for the keyboard layout (what the keys should do)

To apply new settings, restarting the keyboard-setup service with this

 sudo service keyboard-setup restart
αғsнιη
  • 35,660
  • 7
    But how am I supposed to type sudo service keyboard-setup restart if I can't login because of the layout – Cedric Martens Jan 25 '18 at 12:50
  • Why switch to console mode? Can't I just open a terminal? – Colonel Panic Mar 18 '19 at 11:08
  • Ctrl + Alt + F3 for switching to console mode in Ubuntu 18.04 https://askubuntu.com/a/1053220/726213 – Akif Nov 22 '19 at 01:07
  • 1
    This worked specifically when most x.org settings (setxkbmap and localectl ... would not persist after restarts with Kali. Thank you very much. – wgj Mar 05 '20 at 22:01
  • 1
    I've ben looking for this solution for a long time. Really appreciate your answer. Many thanks! – medina May 02 '20 at 04:42
  • I know this thread is old, but maybe the people are still around ;) Is there a way to add a second keyboard? This solution replaces the existing layout – ElRudi Jan 17 '21 at 11:07
  • 1
    To answer some questions from the comments: Depending on how/where OP set the layout, this change only affects the desktop session, but not the tty consoles (where the login screen gets its layout from depends on the flavor of Ubuntu). Hence we need Ctrl + Alt + F3 to switch to a tty console, which (hopefully) still has the Swedish layout so OP can enter their password. Of course one could run these commands from a terminal, but only after you manage to log into a desktop session. – user149408 Apr 21 '21 at 11:01
  • This also works on encrypted disk password login screen. Thank you ! – asandikci Sep 21 '22 at 19:17
  • @CedricMartens For me the only way was to figure out what layout I'm stuck with and adjust my keystrokes accordingly. One can switch the password field to cleartext mode and press the topleft-most six keys. In my case, instead of the expected QWERTZ there appeared AZERTY, so I knew it must be a French variant. I just googled "azerty" and with the help of a layout map managed to type my password. – Christallkeks Jun 15 '23 at 07:57
4

This works for me: Change de variable XKBVARIANT = “us”, on file /etc/default/keyboard to the name of layout you want and reboot.

  • For me it was a french "afnor" and I switched to "azerty". It was a shot in the dark however, I wonder where one could find a list of all available variants – Axel B Jul 11 '22 at 11:10
  • you can try localectl list-x11-keymap-layouts or localectl list-x11-keymap-variants – Gabriel Bueno Jul 12 '22 at 13:25
  • That's excatly what I meant ! Thanks ! – Axel B Jul 15 '22 at 08:20
  • @AxelB The file /usr/share/X11/xkb/rules/xorg.lst contains a list of all available variants. Source: https://manpages.ubuntu.com/manpages/bionic/en/man5/keyboard.5.html#files (and tried it myself) – Christallkeks Jun 15 '23 at 07:43
1

This is an old post, but recently I have faced with the same issue and the solution above did not help.

During the Linux Mint installation, I accidentally selected the wrong keyboard layout. Later I fixed it by removing the old one and adding the proper keyboard, but unfortunately, this had no impact on the login screen.

Solution:

  1. login and show your current, working layout configuration with setxkbmap -print -verbose 10
  2. check the layout that is used on the login screen: cat /etc/default/keyboard
  3. set up properly the login screen keyboard layout with sudo dpkg-reconfigure keyboard-configuration

That was the only solution that worked for me. I hope that it helps you as well.

zappee
  • 977
0

For anyone who's been facing the same problem and nothing worked here's an idea boot from the recovery mode then scroll down to root then write the following command to reset your password "passwd yourUserName" then enter your new password for that username hope this helps :)

  • Wouldn’t it be possible to run sudo dpkg-reconfigure keyboard-configuration in recovery mode and revert to a keyboard layout that has all the characters needed for recovery mode? – user149408 Apr 23 '21 at 16:26
0
  1. Use tty3 using Ctrl+Alt+F3

  2. sudo nano /etc/default/keyboard to look like this:

    # KEYBOARD CONFIGURATION FILE
    

    Consult the keyboard(5) manual page.

    XKBMODEL="macbook78"<br> XKBLAYOUT="de"<br> XKBVARIANT="basic"<br> XKBOPTIONS=""<br>

    BACKSPACE="guess"

  3. sudo setupcon

  4. reboot

After that it changed my layout.

Daniel T
  • 4,594
0

In GNOME 42, localectl told me VC Keymap: n/a.

Running sudo localectl set-x11-keymap dk set the login screen layout to Danish.

I have no input source selection available under Region & Languages > Login Screen.

See further this GNOME help page

Rasmus
  • 8,375
0

I just had the same problem on Ubuntu 22. On the login screen click on the accessibility options and activate the screen keyboard, then you should be able to get your special character and login.

Then once logged in, you should be able to do the proper configuration described by the other answers.