Can’t Login Ubuntu GUI (Login Loop)

PowerADM.com / Linux / Ubuntu / Can’t Login Ubuntu GUI (Login Loop)

In this article, we’re going to look at the Ubuntu login issue related to GUI and desktop loading problems, which results in an endless password loop. After entering the correct password, instead of loading the graphical environment, a black screen appears, and then the password prompt appears again (and so on in a loop). As a result, the user cannot log into the Ubuntu GUI. This problem is called Login Loop.

Ubuntu gets stuck in a login loop

To solve the problem you need to open the Ubuntu console. To do this, press the Ctrl+Alt+F2 key combination (or any key from F1 to F6) right on the login screen. This should open a tty2 console window. Enter your username and password and log in Ubuntu.

Access terminal from login screen

Try running the Gnome GUI Shell with the startx command. Examine the startup log carefully for errors.

Newer versions of Ubuntu (including Ubuntu 22.04 LTS) use GDM3 as the default display manager in the GNOME environment. The GNOME Display Manager (GDM) is responsible for the graphical interface and, among other things, for user login via the GUI.

Check that the service is installed and running:

sudo systemctl status gdm.service

Try restarting the login manager:

sudo systemctl restart display-manager

You can use the following command to reinstall GDM:

sudo apt -y --reinstall install gdm3

If you get a black screen at boot and GDM does not start until you touch the mouse or press a key on the keyboard, you should check for the following error in journalctl --unit systemd-random-seed:

Kernel entropy pool is not initialized yet, waiting until it is.

To solve this problem for AMD64 processors with RDRAND instruction support, add the kernel parameter random.trust_cpu=on.

You can test the support of this parameter as follows:

grep CONFIG_RANDOM_TRUST_CPU /boot/config-$(uname -r) && grep rdrand /proc/cpuinfo && echo "your system looks fine"

After making the changes, press Alt+→ several times (or Ctrl + Alt + F7) to switch from the text console to the graphical login screen in Ubuntu.

Some basic tips for solving problems with the Ubuntu graphics subsystem.

  1. Make sure there is enough free space on the disk:
    $ df -h

    If there is no space left on the device in your home directory, Ubuntu will not be able to create temporary files

  2. Complete the failed or pending updates (if the problem occurred after the updates were installed):
    $ sudo apt update
    $ sudo apt -y full-upgrade

    Clean the system of unnecessary packages:

    $ sudo apt -y autoremove
    $ sudo apt -y clean
  3. Check the permissions on the ~/.Xauthority file. The Xauthority file stores the credentials and cookies used by xauth to authenticate to an X session. When starting an X session, it uses the session cookie to authenticate the connection to a particular display. If you are not the owner of the file and cannot write cookies to it, you will not be able to authenticate the connection to the display and will be returned to the login screen. On older Ubuntu distros, the Xauthority file is located in the home folder:
    $ ls -l ~/.Xauthority

    Change file permissions with chown:

    sudo chown username:username ~/.Xauthority

    In newer versions of Ubuntu, the file path is /run/user/user_id/gdm/Xauthority

    $ ls -l /run/user/user_id/gdm/Xauthority
  4. Check the permissions on the /tmp folder. It must be accessible to all users for reading and writing. List current permissions:
    $ ls -l / | grep /tmp

    Set correct permissions:

    $ sudo chmod 1777 /tmp
  5. Using the /etc/X11/xorg.conf file may cause display problems when booting Ubuntu. It is recommended to use the default X11 config file /usr/share/X11/xorg.conf.d. Try to delete the xorg.conf file:
    sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.old/code>
  6. Reinstall the GNOME graphical manager (responsible, among other things, for processing the Ubuntu login screen):
    sudo apt install --reinstall gdm3 ubuntu-desktop gnome-shell
    sudo systemctl reboot
  7. In some cases, a complete reinstallation of the graphics subsystem packages can help:
    sudo apt-get purge xorg "xserver-*"
    sudo apt-get purge lightdm plymouth
    sudo rm -rf /etc/X11/xorg
    sudo apt-get autoremove
    sudo apt-get install xauth xorg openbox lightdm plymouth
    sudo apt-get install ubuntu-desktop
    sudo reboot
Leave a Reply

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