I installed Ubuntu 18.04 yesterday, done some app installation and configurations and went to sleep. This morning, the login simply didn't work: the system is unable to log into my session, even with the correct password. Every time I try it, it flashes the screen into black and purple, the mouse pointer is available, but it flashes back to the login screen again: no error message prompts and I spent quite some time amusing myself trying to win it by attrition =). I also tried switch over to Wayland, and the same result: screen flashes to black, couple of seconds later, I'm back at the login stage.

There is nothing wrong with my password, since I can log into my user account on the Terminal (CTRL+ALT+F1). Once there, I did a sudo apt update/upgrade in the hopes it'd fix something, but my system was up to date and it didn't solve anything after I rebooted.

I've seen a lot of similar reports on the internet and the only solution that it seemed worthwhile to my noobish eyes was removing/deleting the .Xauthority file. But when I tried it, the return I got was that there was no such file on my Home directory. The other solutions applied to people upgrading their systems - mine was a fresh install - or with pretty specific hardware and conditions that don't apply to me.

So, what should I do to fix this?

  • 2
    Possible duplicate of Ubuntu gets stuck in a login loop
    – Elder Geek
    Jul 25, 2018 at 21:43
  • Did you find a solution for this? I have the same problem and the solution mentioned on the above link does not work for Ubuntu 18.04
    – Sumit
    Sep 25, 2018 at 6:37
  • Check again ls -l ~/.Xauthority ls -l ~/.ICEauthority ls -ld ~
    – Vijay
    Oct 30, 2018 at 15:35

19 Answers 19


I had the same problem.
Then I found out that I accidentally changed the ownership of my /home/username directory to root.

So you can go to the terminal by CTRL+ALT+F1, and change the username directory ownership with

sudo chown <username>:<username> -R /home/<username>
  • 3
    This saved me after a whole morning of headache, thank you!
    – FMM
    Apr 24, 2019 at 10:06
  • 1
    Same situation for me on Ubuntu 19. How did it happen? Likely me working with not enough sleep and doing a chown on the wrong folder. Fix was as shown above. May 21, 2019 at 2:37
  • 1
    I had the same problem. /home/user was owned by root:root instead of user:user thanks! Dec 17, 2019 at 0:20
  • 1
    Thanks, this solved one of my issue
    – MACMAN
    Nov 26, 2020 at 5:51
  • 1
    Thanks, I accidentally changed whole ubuntu permission from another ubuntu May 1, 2021 at 15:40

Login loop issues, type Ctrl+Alt+F3, at terminal login, if your password is correct, all is well, then at prompt type startx, then you see your desktop. The worked on two computers.

  • Although this didn't work for me, it helped me identify the issue. After startx, I couldn't login but I got to see the error log associated with my problem. In my case I didn't have enough storage on my home. Oct 10, 2019 at 7:09
  • Tried couple methods do not work but eventually startx workable... May 1, 2021 at 14:39
  • Startx solved my problem on 18.02
    – amol goel
    May 10 at 1:56

I just spent WAAAY too much time solving this issue. What finally solved the issue was replacing the /usr/local/lib/libreadline.so.7 library with a link to /lib/x86_64-linux-gnu/libreadline.so.7

sudo mv /usr/local/lib/libreadline.so.7 /usr/local/lib/back.libreadline.so.7
sudo mv /usr/local/lib/libreadline.so   /usr/local/lib/back.libreadline.so
sudo ln -s /lib/x86_64-linux-gnu/libreadline.so.7  /usr/local/lib/libreadline.so.7
sudo ln -s /usr/local/lib/libreadline.so.7  /usr/local/lib/libreadline.so

A good indication that there was a problem was that gawk did not work because of the same missing external in libreadline with:

$ gawk
gawk: symbol lookup error: /usr/local/lib/libreadline.so.7: undefined symbol: UP

My ~/.Xauthority was fine, no amounts of updates made any difference. Right after my upgrade from to Ubuntu 18.04.1, my system would stop booting in the middle somewhere. I switched to lightdm from gdm3 with

sudo dpkg-reconfigure lightdm

and the system would boot but then I could not login.

I hope this can help somebody.


I experienced this issu in debian I installed node.js and i added it into the path when i rebooted it takes me to a login loop I used to pass in CLI by Ctr Alt F2 and deleted the extra link i added to path Then i Ctr Alt F1 returned to GUI and authentificated normally


Experienced the same problem today for the first time since moving on to Beaver. Weirdly immediately post full wizard install.
Initially I thought it was a Wayland issue but despite attempts to force other compositors the issue remained until I cracked-open a Shell and removed my freshly created user /home folder. Upon the next initialisation of my chosen GDM I was shown the new user config wizard and all has been fine since.


I ended up solving this by disabling secure boot on my notebook. As I understand, my issue was caused by wonky Nvidia drivers.


I just faced this issue on my Ubuntu 18.04. Putting correct credentials, would flash a blank screen and go back to the login again.

So I Alt-Ctrl-F3 and tried almost all the answers from Ubuntu gets stuck in a login loop, none worked.

Then I decided to find any clue on /var/log/syslog. One of the errors popping up there would be related to flatpak, where a Permission Denied error was thrown when trying to read one of this package's file.

Then I remembered one of the things I did the day before was installing flatpak for some reason, but ended up not using it.

So I just apt purge flatpak && apt autoremove and logging in worked again.

HINT: check syslog for anything unusual and that might relate to something you did recently.


This is due to the ownership on /home/username directory having been changed to root.

We can check this with ls -lh /home/:

$ ls -lh /home/

drwxr-xr-x 26 root root 4.0K Oct 26 19:08 username

To fix this, open a TTY window with CTRL+ALT+F2, and change the username directory ownership from root to username with the command:

sudo chown username:username -R /home/username

Check ls -lh /home/ again to verify the change was successful:

$ ls -lh /home/

drwxr-xr-x 26 username username 4.0K Oct 26 19:08 username

Press CTRL+ALT+F1 to leave the TTY and go back to your desktop.


I installed Gnome Global Application Menu (HUD for Gnome) at the extensions.gnome.org website (already had Gnome Shell Extensions installed). The computer needed to restart. After the computer rebooted, it got stuck in a login loop with LightDM. (I have also installed Unity for 18.04.) I could enter the Unity version but not the Gnome or Wayland version.

Solution: If you can get to a command prompt (Ctrl+Alt+F1, to exit: Ctrl+Alt+F7), view the installed Gnome shell extensions with this:

ls ~/.local/share/gnome-shell/extensions

I disabled the nefarious extension (gnomeGlobalAppMenu@lestcape) with this:

gnome-shell-extension-tool -d gnomeGlobalAppMenu@lestcape

I was able to log in after this. I'm not certain, but it was probably conflicting with the Dash to Panel extension.


In my case, the issue was linked to my home directory beeing encrypted with ecryptfs, it seems.

I logged in to the console (Ctrl+Alt+F1), and installed ecryptfs-utils :

sudo apt-get install ecryptfs-utils

It solved the problem.


Are you using Xorg? Check the /var/log/Xorg.0.log first.

I ran into a similar issue. I saw a error message in the Xorg log complaining about a missing symbol drmModeListLessees. I searched this symbol in the libdrm libraries and didn't find it.

Then I downloaded libdrm-2.4.91 and installed the libdrm to overwrite the ones on the system. Finally the startx can work without any error.


I upgraded my Ubuntu 16.04 to 18.04.3 with the updater and thereafter it got into a login loop. I pressed ctrl+alt+F3/F4 to log into the console terminal and tried some of the suggested commands but in vain.

sudo apt-get -y install lightdm/gdm3
sudo apt-get -y install lubuntu-desktop
sudo reboot

also verified the owner and group of .Xauthority and /tmp

chown <username>:<username> .Xauthority
sudo chmod a+wt /tmp

reconfigured lightdm

dpkg-reconfigure lightdm
sudo service lightdm restart

and checked the log files with no errors.


To me, the only solution is to install a new 18.04.3. The following are my notes on how to save and restore user data during the reinstall.

  1. Insert a USB flash drive and find its drive with

    sudo fdisk -l | grep sd

    lsblk -l | grep sd

  2. Suppose the drive is /dev/sdb1, mount it to /mnt or /media

    sudo mount /dev/sdb1 /mnt

  3. cd to ~/Documents where the user data resides and tar it

    tar -cvf Ubuntu_16_04_Doc_Save.tar

    gzip Ubuntu_16_04_Doc_Save.tar

  4. cp or mv the resultant file to the USB drive

    mv Ubuntu_16_04_Doc_Save.tar.gz /mnt

  5. Insert a bootable Ubuntu 18.04.3 USB flash drive, reboot and hit F12 to select the USB boot option to install the Ubuntu.

  6. When finished, log in and verified it with

    lsb_release -a

    Description: Ubuntu 18.04.3 LTS

  7. Insert the saved USB drive and repeat steps 1 through 4 except to untar it.

  8. cd ~; rmdir Documents;

    mv /mnt/Ubuntu_16_04_Doc_Save.tar.gz .

    tar xvfz /mnt/Ubuntu_16_04_Doc_Save.tar.gz

Now we have restored the user data in ~/Documents.


For a fresh install if you get this error like I did and none of the recommendations worked such as renaming the .Xauthority file when you do not have one, the issue is with the Ubuntu installation step when you choose "Install 3rd party software". There is some software being installed that is causing the issue, at least in my case it was. I unchecked this option and when the installer finished, I rebooted and was able to log in.

I manually installed my GPU driver for Nvidia and all is well. Perhaps it's the version of the Nvidia driver that is being installed during the fresh install that is causing the issue? In any case, try this method and you should be ok. You just have to install 3rd party software on your own.


I upgraded the packages from my Ubuntu 18.04 yesterday and today I couldn't login anymore.

The solution for me was to deactivate Wayland in /etc/gdm3/custom.conf I uncommented the line WaylandEnable=false so that it looked like this.

I did this at the Recovery mode from the grub menu. To initiate grub, reboot and hold SHIFT key.

Note: LightDM is the display manager running in Ubuntu up to version 16.04 LTS but it has been replaced by GDM in later Ubuntu releases (https://wiki.ubuntu.com/LightDM).


For me, this problem was caused by not having the /bin directory in my PATH environment variable. I had edited the /home//.profile file, intending to add a location to my PATH when instead I accidentally replaced the PATH altogether. Removing the offending line allowed me to log in again.


Ran into a similar issue today. Ended up being an issue with a USB device. (a phone I was charging) Spent 30m tailing log files and trying to figure it out, only real error I found was a pulseaudio permission denied error. I unplugged the phone on a whim. Next attempt to login was successful.


I've had this happen for one user account on Ubuntu and it was caused by something screwy in the user's ~/.config directory. To quickly fix, switch to log in as the user via the console (Ctrl-Alt-F3 or similar) then at the prompt do mv ~/.config ~/config.old. Switch back to the GUI (Ctrl-Alt-F1 or similar) and you should be able to log in. Note that all config settings (background etc.) will be back to defaults.


If changing permission of .Xauthority or .ICEauthority or reinstalling gdm3/lightdm doesn't work then the failed login is due to another reason. One way to find out is to read the recent lines in /var/log/syslog. First, press Ctrl + F3 and login, then:

tail -n 50 /var/log/syslog

On my computer, there's a line indicated something like /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.1: invalid ELF header. So I located and copied the intact version over:

locate libcrypto.so.1.0.0
# use the path of the libraries from the output of previous command
sudo copy /snap/core/11187/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0

Press Ctrl + F1 to check log-in.

Failed GUI log-in may be due to a lot of reasons. It is important to find out why before fixing.

  1. Switch to terminal by ctrl + alt + f3
  2. Login using your username and password.
  3. Type startx command.
  4. Now you should see your desktop.
  5. Undo any last configes might caused the issue. In my case, an accidental change in /etc/environment file.
  6. Restart I hope this could help! Note:If the cursor doesn't respond after logging using startx command, KDE connect application could help by controlling your desktop remotely using your phone as a mouse or just trigger the terminal window: ctrl + alt + T

Not the answer you're looking for? Browse other questions tagged or ask your own question.