The “Ubuntu login loop” is one of the most notorious desktop glitches in Linux. You sit at your computer, type your correct user password at the GDM or LightDM login prompt, the screen flashes black for a split second, and you are immediately returned to the exact same login screen with no error message provided.
This endless loop occurs when the display manager successfully authenticates your credentials, but the GNOME or desktop session crashes instantly during startup. Common causes include corrupted permissions on the .Xauthority session token file, an entirely full root partition (0% disk space remaining), or broken NVIDIA proprietary graphics driver modules. This guide details how to enter a virtual console and resolve the underlying session crash.
Method 1: Access the Virtual Terminal (TTY)
Because the graphical desktop environment is unable to initialise, you must perform recovery steps from an alternate text-based terminal console.
- At the graphical login screen, press Ctrl + Alt + F3 (or Ctrl + Alt + F4 / F5 depending on your keyboard configuration).
- The graphical screen will disappear and present a black text console with a
login:prompt. - Type your regular Ubuntu username and press Enter.
- Type your password and press Enter (note that no asterisks or characters will show while typing your password).
- You now have full administrative shell access to diagnose the system.
Method 2: Check for a Full Disk Partition
When Ubuntu’s root storage partition fills up completely (100% capacity), the session manager cannot write temporary runtime socket files to /tmp, causing the graphical desktop to abort instantly upon login.
- In the TTY console, check your filesystem disk usage by running:
df -h / - Inspect the Use% column. If it reads 100% or shows 0 bytes available, disk exhaustion is the direct cause of the login loop.
- Free up immediate emergency disk space by cleaning the APT package archive:
sudo apt-get clean - Vacuum systemd system journal logs older than 2 days:
sudo journalctl --vacuum-time=2d - Remove old kernel versions that are no longer needed:
sudo apt-get autoremove --purge - Clear user thumbnail caches:
rm -rf ~/.cache/thumbnails/* - Once disk space drops below 90%, return to the graphical login by pressing Ctrl + Alt + F1 (or Ctrl + Alt + F2) and log in normally.
Method 3: Correct .Xauthority File Ownership and Permissions
If you accidentally ran graphical applications using sudo (such as sudo gedit or sudo nautilus) in a previous session, the root account may have taken ownership of your user’s .Xauthority token file. When you attempt to log in as a normal user, your account is forbidden from writing to its own session file.
- In your TTY text console, navigate to your user home directory:
cd ~ - Inspect the ownership of hidden X11 session files:
ls -la .Xauthority* - If the owner is listed as root instead of your username, correct the file ownership:
sudo chown $USER:$USER .Xauthority - If you receive an error or multiple corrupt authority files exist, safely remove the file (Ubuntu will automatically generate a fresh one upon successful login):
rm -f ~/.Xauthority - Ensure your
/tmpdirectory possesses correct sticky-bit permissions:sudo chmod a+wt /tmp - Reboot the system:
sudo reboot
Method 4: Reinstall or Reconfigure Graphics Drivers
If a recent system update replaced the Linux kernel without rebuilding dynamic kernel modules (DKMS) for proprietary NVIDIA display drivers, GNOME Shell and Wayland will crash during session start.
- Log in to the TTY console (Ctrl + Alt + F3).
- Purge any broken NVIDIA driver installations:
sudo apt-get purge 'nvidia*' - Instruct Ubuntu to automatically detect hardware and install the recommended stable graphics driver:
sudo ubuntu-drivers autoinstall - Reinstall the desktop environment packages to ensure display manager configurations are intact:
sudo apt-get install --reinstall ubuntu-desktop - Reboot your system:
sudo reboot
Ubuntu Login Loop Diagnostic Reference
The table below provides a quick reference for the primary triggers behind the Ubuntu login loop:
| Underlying Cause | Diagnostic Command | Remedy |
|---|---|---|
| Full root disk partition | df -h / |
sudo apt-get clean && sudo journalctl --vacuum-size=100M |
| Root-owned .Xauthority file | ls -l ~/.Xauthority |
sudo chown $USER:$USER ~/.Xauthority |
| Corrupted /tmp permissions | ls -ld /tmp |
sudo chmod a+wt /tmp |
| Broken graphics driver module | dmesg | grep -i nvidia |
sudo ubuntu-drivers autoinstall && sudo reboot |
Preventing Future Session Login Failures
To avoid recurring login freezes, never run graphical desktop applications using standard sudo. Instead, use pkexec or terminal-based editors like nano when editing root system configuration files. Regularly monitoring disk capacity prevents full partitions from blocking desktop session handshakes.