How I Broke Ubuntu and Killed a Day to Fix it

The approach to solving the login problem outlined in this article is not a silver bullet and may not work. Perhaps there are other ways to get out of the situation, I am sharing the one that worked in my case.

Have you ever had a Snapd User Session Agent enter an endless loop? You enter the correct password and… you are taken to the same login screen.

It’s wide famous situation that can occur due to a variety of factors. No less widely known is the universal recipe: get into the bash terminal via tty (Ctrl + Alt + F1), find the problem and fix it.

However, what if you can’t get into the terminal for some reason? For example, is your default keyboard layout different from your username and password? I would like to devote an article to this special case, since I spent a lot of time and even more – nerve cells on it.

So, this is the first time you’ve encountered an infinite login loop and you’re trying to log into a terminal using a tty. But here you are met by the “native” Russian layout instead of the English one. No hotkeys work: you’ve tried Shift + Alt, Alt + Shift, Cmd (Win) + Space and every last one. Nothing helps. You can stress as much as you like and doubt your sanity (“what an idiot do you have to be to set the Russian layout as the main one on an Ubuntu machine???”), but this does not cancel the impasse. As a result, entry is impossible. You reboot the machine, hold down Esc (sometimes also Shift, but not in my case) to get into the grub menu and enter recovery mode. But – oh horror – and here you are haunted by the hated Russian layout.

In the vast forums and StackOverflow threads, you will meet people who have reached this stage because of the Greek or Russian layout and despaired, simply reinstalling the operating system from a flash drive or other physical drive. Don’t do it, suicide is not an option.

So, restart the machine again and get into the grub menu by holding Esc or Shift. In the menu, select the Advanced options for Ubuntu option.

Once on the topmost option `Ubuntu with Linux… generic`, press E (aka Edit) on the keyboard. In the kernel line (beginning with linux) at the end, separated by a space, add init=/bin/bash and press Ctrl + X (start with these changes).

You will be taken to the bash terminal and finally see the English layout, which you already despaired of ever returning. Last effort – edit the file keyboardwhich is located in /etc/default. First run the command mount -o remount,rw /so as not to run into a Read-only File System error.

You will probably find a line like this or similar in this file:

XKBLAYOUT="ru,us"

All you need to do, you guessed it, is to swap the cherished keywords ru and us with nano or any other editor. After that, you can restart the computer and enter bash through tty.

The probability of encountering such a problem is negligible, because for this you need

  1. love Ubuntu so much that it’s your only OS on your computer

  2. set the Russian layout as the default for the system

  3. catch loopback bug with Snapd User Agent

  4. find that hotkeys do not work in tty (assuming that the same Shift + Alt can work on another machine).

Nevertheless, I hope that this article will find its reader and allow him to save time and nerves.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *