573

My Ubuntu is stuck in a login loop when trying to enter my desktop. When I login, the screen gets black and soon after that the login screen comes back.

I've read that the problem might be caused by an error depending on the graphics, here's my graphics card: ATI Radeon 7670M

Aaron Hall
  • 1,059
  • 2
  • 13
  • 22
  • 28
    Look in ~/.xsession-errors; there might be a clue there. – offby1 Apr 21 '12 at 23:09
  • @CalvinWahlers Since you installed Quantal, you couldn't start the system correctly? Have you installed drivers some? Could you connect from some TTY (Ctrl+Alt+F1..F6) with any user? – Lucio Nov 30 '12 at 02:13
  • no, it worked fin for I think month... But suddenly that happened – Calvin Wahlers Nov 30 '12 at 12:45
  • seems that I can't post an answer. I had a similar problem and after trying all workarounds mentioned here with no success, I found that my sessions where messed up in /usr/share/xsessions. Moved all files there to my /home dir (to have a copy) and tried to login using kdm (I use Kubuntu). To select kdm as login screen, I executed sudo dpkg-reconfigure lightdm and selected kdm. With kdm you can select a previous session or a default one. This was the way to go. – Ivan Ferrer Villa Feb 12 '14 at 21:40
  • I have same graphics card ATI Radeon HD 7500/7600 M. I also got into bootloop yesterday. Reason : I did a restore using sbackup, everything worked but after restart I got into login loop. For me nothing mentioned in answers worked so i did a fresh system install. I commented my part so that any link between both can help community. Things i restored were folders : home, etc,usr,var. – study-route Jul 07 '15 at 14:03
  • Just as a note that I had this same issue but was caused by a disk that was full. I logged into shell, ran some du commands and realized it was due to a process I left running on my computer for a long period of time. I deleted some of the 50+ GB log files and all was restored – Dan King Sep 13 '16 at 02:30
  • 5
    I had the same problem and it was simple. My Virtualbox Lubuntu 16.04 had run out of disk space. I cleared some space and - Shazam! Back again. – Ignorante Sep 20 '16 at 16:03
  • 5
    I don't have enough reputation to answer, but what worked for me was following instructions here. In short do sudo ubuntu-drivers devices, and then sudo apt-get install the recommended driver. – kabdulla Apr 04 '17 at 07:05
  • The most likely cause of this issue is syntax errors in ~/.profile as implied by Dan Cundiff's answer. Much more likely than all the other suggestions. You fuck up your .profile, and you can't log in next time. That simple. – Daniel Dinnyes May 27 '18 at 21:44
  • 2
    after trying many ways, I found that the problem was because of installing indicator-multiload . With purging it my problem resolved. I can not answer so I write my experience as comment!! – Nik Kashi Jun 20 '18 at 04:30
  • Guys, I managed to fix the exact problem. Background, my machine (desktop) runs 16.04 with latest patches up until June 2018 12Gb Ram. Having tried most solutions offered, I found the problem was missing /usr/bin from the PATH. The way to find it, if you do have this problem is: When you get your login screen drop to the terminal by issuing ctrl+alt+f1 then issue any command IE vim if you get an error "The command could not be located because /usr/bin is not included... Then you have the same problem. Edit the file /etc/environment add :/usr/bin: save it / exit /reboot. – malypetu Jun 29 '18 at 03:36
  • I just had this error on my freshly installed vbox Debian. I tried everything mentoined below in the accepted answer, but didn't worked. I logged into recovery mode and I noticed that a zero-fill file (which I created to minimize the disk space) didn't deleted by the last command of my script... I think it's worth to note that non-available disk space can also create similar issue, where you think there's some problem with lightdm. – Lanti Oct 20 '18 at 20:40
  • Happened to me today, Ubuntu 18.04. Curisouly, just restarting the machine did the trick. Go figure. – Lucio Paiva Mar 09 '19 at 21:03
  • 2
    Happened to me today, Ubuntu 18.04. If none of the answers here work, look at /var/log/syslogand check for any error that might relate to something you did recently. My issue was an error related to flatpak, which I've installed the day before but ended up not needing it. After uninstalling it, everything went back to normal. – dferrazm Jun 06 '19 at 10:00
  • I have tried all the answers, but I still have problem with login. – Mostafa Ghadimi Sep 07 '19 at 09:43
  • 1
    There is one more possible reason . If you mess up the /etc/environment file then also it can happen. To fix . do ctrl+alt_+F3 and login to session. check if you can run any shell command. if not then that's the problem. – xpioneer Dec 07 '19 at 04:28
  • In my case it was a NVIDIA problem and this helped: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux Thanks to ubuntu-drivers devices I could see that I needed to install recommended driver so sudo ubuntu-drivers autoinstall fixed it – diegosasw Mar 26 '20 at 10:04
  • I think I have a situation that isn't mentioned elsewhere on this page. I had upgraded to 20.04 and found that logging into GNOME failed (and Wayland worked). I had to run ampgpu-pro-uninstall to get rid of the old drivers and the standard ones built in seem to work fine. Can't do a proper answer - not enough rep. – kennyB Jun 02 '20 at 02:27
  • 1
    Wow. This question is from 2012, and I'm having this problem on a fresh install of the last version in 2020. It's seems that Canonical spends all of its resources designing fancy buttons. What a joke. – cangrejo Sep 02 '20 at 10:33
  • 1
    For me this problem appeared after I enabled the Automatic Login option.. To fix this I opened the command prompt (Ctrl+Alt+F7), created a guest user via sudo adduser myguest and logged in with it to disable the Automatic Login option... – Mr. Blond Sep 09 '20 at 18:21
  • 1
    In my case the issue was in ~/.profile including ~/.zshrc. I don't know if I made this mistake or if it happened after I had installed Oh My Zsh (I think so) – felipsmartins Aug 23 '22 at 22:14
  • Try switching to Ubuntu on Wayland on the login screen, it helped in my case – Dmitriy Pavlukhin Oct 08 '22 at 11:19
  • @felipsmartins boy, this might be the reason it fails for me 2 :-O I had this issue on all my distro installation in the last 4 months, Ubuntu, Debian & Fedora. All had the same issue, nobody else in my neighbourhood so hard to tell what the reason was/is. – jaques-sam Apr 05 '23 at 17:50
  • 1
    @jaques-sam glad this worked for you – felipsmartins Apr 05 '23 at 18:44
  • Happened to me too on Ubuntu 18.04. I looked at /var/log/syslog/ and found error message JS Error: TypeError: malformed UTF-8 character sequence at offset.........org/gnome/shell/ui/main.js...... I deleted in my home directory the folder gnome-shell - the path is home/<your user>/.local/share/gnome-shell. This solved my login loop and I was able to login as normal. – David Miller Mar 23 '24 at 15:22

52 Answers52

462

Did you end up here after running sudo startx? Nevertheless:

Press Ctrl+Alt+F3 and login into the shell.

Now run ls -lA. If you see the line

-rw-------  1 root root   53 Nov 29 10:19 .Xauthority

then you need to do chown username:username .Xauthority and try logging in (you may also need to do the same for for .ICEauthority).

Else, do ls -ld /tmp. Check for the first 10 letters in the left: they should read exactly so: drwxrwxrwt.

drwxrwxrwt 15 root root 4096 Nov 30 04:17 /tmp

Else, you need to do sudo chmod a+wt /tmp and check again.

If not both, I'd recommend you either

  1. sudo dpkg-reconfigure lightdm
  2. or uninstall, reinstall it.

Now press Alt+ until you reach the login screen again, and restart.

Byte Commander
  • 107,489
SiddharthaRT
  • 6,066
  • 21
    I've same problem, chown username:username .Xauthority helped. But, anyone has an explanation? – ts01 Jan 23 '13 at 08:41
  • @ts01 I think my problem was "gdm-session-worker crashed with SIGSEGV in act_user_is_loaded()" – Elzo Valugi Feb 11 '13 at 17:13
  • 1
    I did delete the /tmp folder manually I probably was not a good idea for gdm. – Elzo Valugi Feb 11 '13 at 17:16
  • 16
    I actually even had to remove my .Xauthority for things to work. For some reasons, none of the above solved my problem. – jlengrand Oct 15 '13 at 08:51
  • 1
    both deleting /tmp and .Xauthority will cause Ubuntu to recreate those folders/files with right permission on next bootup. This is an (unintended) way of doing what i suggested first. – SiddharthaRT Oct 24 '13 at 12:22
  • 75
    This was exactly my problem. Couldn't the devs think of something simple like popping up "Permission denied while attempting to edit /home/username/.Xauthority. Ensure username has read/write permissions."? This could have saved the 41000 people who have viewed this question so far some huge headaches. – Mike Dec 22 '13 at 06:18
  • 15
    +1 - Although I had to do this for both .Xauthority and .ICEauthority – Aust Jan 17 '14 at 16:00
  • 3
    Once I fixed this problem by reinstalling xserver-xorg. The second time Gnome had vanished somehow and I had to reinstall gnome-session-fallback. – Abid H. Mujtaba Apr 02 '14 at 04:28
  • 3
    I've had the same problem, but it was my fault, because I modified /etc/environment to add some environment variables and I made a mistake.

    By following @SiddharthaRT's instructions, I was able to solve the problem.

    You know: /usr/bin/sudo /usr/bin/vi /etc/environment

    – jbbarquero May 08 '14 at 15:44
  • 1
    Thanks for the answer. The chown on .Xauthority fixed that. What can cause that? – Dakkaron Sep 02 '14 at 08:03
  • 2
    I had to chown .Xauthority, .ICEauthority, and .gvfs. This was caused by me running sudo startx from an ssh session, because for some yet undetermined reason, X keeps shutting down – Nacht Sep 20 '14 at 03:16
  • 1
    This happened after installing a VNC server. The fix worked great! – Matt Jan 02 '15 at 20:41
  • 1
    Wohoo! Setting the permissions on /tmp saved my butt. – Brandon Mar 06 '15 at 05:32
  • 1
    +1. In my case .Xauthority was owned by root. In other users' folders, .Xauthority was owned by them. No idea what altered that - I switched from openbox to afterstep and when i logged out, i could get back in – Sergiy Kolodyazhnyy Mar 15 '15 at 06:42
  • 13
    @Nacht DON'T run sudo with startx. Using sudo to run startx is exactly how the permissions of the Xauthority file can get screwed up like this. Run startx as your normal user and it should work. If it doesn't, check the ownership of the .Xauthority file to make sure it's not owned by root again. – mchid Jan 27 '16 at 00:29
  • 4
    The login loop is unfortunately a recurring issue with Ubuntu 14.04; whenever I bump into it I end up at this answer just to check once again that it solves nothing. No idea why it is accepted, since it only addresses a narrow case of file permissions. In most cases the log in loop is caused by bugs with Unity that are not solvable by the user. – Luís de Sousa Mar 07 '16 at 16:10
  • 2

    "anyone has an explanation"... well, by running sudo startx. > "DON'T run sudo with startx... Run startx as your normal user", well if that had worked to begin with we wouldn't be here, now would we?.

    – tresf Mar 11 '16 at 19:30
  • 2
    At least there should be a warning about running startx via sudo. – Vladius Jun 02 '16 at 15:31
  • 2
    Else, do ls -ld /tmp. Check for the first 10 letters in the left: they should read exactly so: drwxrwxrwt. What should I do after the text reads exactly so? – the_random_guy42 Jun 12 '16 at 17:45
  • As most of the people in this comment section, I too (thankfully?) ended up here after running sudo startx. – Priidu Neemre Sep 17 '16 at 02:42
  • Changing owner for .Xauthority worked also for me on Ubuntu 16.04 Desktop – Can YILDIZ Sep 18 '16 at 08:06
  • 1
    i never ran "sudo startx", hell i never typed "startx" either... and i ended up here too :( Ubuntu 16.04 – Jaroslav Záruba Jan 08 '17 at 11:34
  • What if I can't use Ctrl+Alt+F* because my host also is Ubuntu and it goes switching to another terminal? – user1984631 Jan 11 '17 at 08:44
  • 2
    ctrl+alt+f3 and sudo apt-get purge lightdm sudo apt-get install lightdm solved problem. Also what is the difference between ctrl+alt+f1 and ctrl+alt+f3? – mrgloom May 03 '17 at 09:47
  • @mrgloom No difference; ctrl+alt+f1 through f6 are six CLIs that work exactly the same way. – The Guy with The Hat Oct 18 '17 at 15:23
  • .Xauthority file owner shall not be root. – keniee van Apr 02 '18 at 08:30
  • A crashed teamviewer session (daemon running as root) caused this problem for me. Thanks a lot for your help :) – jboockmann Jun 06 '18 at 20:52
  • sudo chmod a+wt /tmp : This doesn't seem to change the letters. I currently stuck have dxwxr-xr-x. I'm going crazy with this loop! – Moondra Aug 13 '18 at 03:23
  • 1
    When i run ls -lA i do get -rw------- but what should it look like once i apply the fix? – Ryan Sep 17 '18 at 12:56
  • Also happened on my raspberry. – gcasar Nov 30 '18 at 18:43
  • I had to search for this answer waaay to long. – Ufos Apr 04 '19 at 13:14
  • @AbidH.Mujtaba Reinstalling xserver-xorg worked for me too, with the caveat that initially it seemed that the installation was unsuccessful (came out with an error that xserver-xorg-core was Broken). However, running startx now works, and the previous issues are fixed. I don't know what to make of this. – Marses Mar 17 '20 at 20:57
  • Actually, after the above I ended up with this related problem (Ubuntu crashing to login screen when trying to open settings): https://askubuntu.com/questions/1049288/ubuntu-18-04-opening-system-setting-logs-me-out But the first answer successfully fixed that too. Seems to be an issue with the xorg driver. – Marses Mar 17 '20 at 21:20
  • It happened to me because I was feeling adventurous, and did a sudo chown -rf 1000:1000 /home/users – GeneCode Sep 17 '20 at 01:30
  • I ran into this issue(possibly) after installing tightvncserver and running sudo tightvncserver. I removed .Xauthority file after reading this answer and the login worked normally after that. – Abinash Dash Mar 15 '21 at 05:27
  • In my case the issue was in ~/.profile including ~/.zshrc. I don't know if I made this mistake or if it happened after I had installed Oh My Zsh (I think so) – felipsmartins Aug 23 '22 at 22:13
80

I had this and after looking at /var/log/Xorg.0.log I found out that it's a Nvidia problem (there was a line saying Xlib: extension "GLX" missing on display ":0).

I realized I have Nvidia drivers from official website which are not really stable and tested (so I've read and also experienced in the past).

The solution here was to install package nvidia-current from Ubuntu repos; it is an awfully outdated version, but it's tested properly at least. Its installer is quite capable too and it uninstalled successfully my hack-installed unstable version from Nvidia website.

TL;DR, just try logging into the shell (Ctrl+Alt+F2 or whatever F between F1 and F6) and type

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-367

If it succeeds, reboot.

sudo reboot

If you're lucky enough, problem solved, you should be able to login to Unity.

UPDATE

Please note that sometimes nvidia-current might install the wrong driver. In that case, search the latest compatible driver for your video card and install it. For example, on Ubuntu 16.04, nvidia-current points to the version: 304.131-0ubuntu3. This might be incompatible with your graphics card; therefore, search with sudo apt-cache search nvidia-[0-9]+$ for the package you need, and install it.

Zanna
  • 70,465
edison23
  • 927
  • 7
  • 16
  • I often have the login loop issue after installing updates. For those who want to use the Nvidia drivers from the website, you need to reinstall them. As you said: Ctrl Alt F1 Login cat .xsession-errors if you have this message Xlib: extension "GLX" missing on display ":0 it means there is a GPU driver issue. Download the nvidia drivers sudo service lightdm stop sudo ./NVIDIA-Linux-x86_64-xxx.xx.run sudo reboot And it should be fine – Mar Cnu Apr 08 '16 at 08:32
  • 1
    I had the same issue. I had to remove all the previously installed drivers; then install "nvidia-361" (right now it's the latest version for ubuntu), run sudo update-initramfs -u, then reboot. unfortunately nvidia-current was installing "nvidia-304" that probably isn't compatible with my video card. But thanks for leading me to the right solution! :) – Markon Jun 04 '16 at 10:03
  • Thanks a bunch, this helped to fix login Issue in 14.04. – Amit Sharma Jul 12 '16 at 05:28
  • 1
    I installed some weird nvidia driver while trying to get the cuda libraries running on my system. doing sudo apt-get purge nvidia* and then getting nvidia-current fixed it (finally after 2 hours). Thanks a ton! – DenverCoder9 Oct 06 '16 at 21:20
  • 1
    I got this problem today when trying to reboot without a keyboard just to experiment with logging in using the onscreen keyboard. Even after rebooting with a keyboard attached I was still stuck in the loop. I had some days before installed the nvidia-current, so today I tried sudo apt-get install nvidia-367 and that seems to have fixed it. Maybe I should have removed or purged previous drivers but I didn't, seems to have done that by itself. – lost baby Nov 04 '16 at 14:13
  • Same for me, but I had to use the solution suggested in this answer. – totymedli Nov 28 '16 at 10:57
  • I didn't listen and installed 'nvidia-375' which didn't help. Following instructions and installing 'nvidia-367' worked ;) Thanks! – nana Jan 14 '17 at 04:39
  • Thanks. Worked for me by replacing the nvidia driver version to the supported one by my card. So it is better to check first for the right driver version for your system before writing down the version number here. – DigitalFox Jul 11 '17 at 12:17
  • For me this was the correct answer. – Tom Busby Jan 11 '18 at 13:52
  • I'm getting permission denied when trying to run this: /var/log/Xorg.0.log – Moondra Aug 13 '18 at 03:26
  • 2
    @Moondra: that is a log, why would you try to run it? A/w, sudo is needed for operations (read, write) on these files, I believe (can't test it now) – edison23 Aug 14 '18 at 15:52
  • This did not work for me.

    ace@ace-hole ~ $ sudo apt install nvidia-367 | [sudo] password for user: | Reading package lists... Done | Building dependency tree | Reading state information... Done | Package nvidia-367 is not available, but is referred to by another package. | This may mean that the package is missing, has been obsoleted, or | is only available from another source | E: Package 'nvidia-367' has no installation candidate

    – ryvantage Mar 25 '20 at 04:57
70

I encountered this exact problem and none of the suggested fixes above worked for me. After almost giving up I looked at the .xsession-errors and noticed I had a typo in my .profile (I had an extra } in the file after I edited it earlier in the day).

That was causing the login loop. It might be another place to look if the other suggested fixes don't work for you.

slm
  • 3,035
  • 2
    My situation was very similar. I had recently added a run function for running commands multiple times in my .profile and that function, though it worked as advertised, seems to have been the cause of my problem. Commenting it out fixed it. – Patrick Jun 06 '13 at 16:05
  • This worked for me. My PC lost power during an electrical storm and some how I ended up with a extraneous line at the end of my .profile. No clue how it got there. Anyway, I'd say the general solution should just be to check .xsession-errors and see what it says. – Brandon Yates Jun 07 '13 at 15:57
  • 2
    This is a good one! I hit the same lightdm login loop problem, spent 30 mins troubelshooting with no luck (tried all possible workaround I can find). Turned out to be a syntax error in ~/.profile caused by rbenv. – Terry Wang Oct 07 '13 at 02:58
  • 2
    This solved my problem - failing line in ~/.profile – Joshua Nov 09 '13 at 01:39
  • 6
    +1 - Thanks for mentioning .xsession-errors – Aust Jan 17 '14 at 15:59
  • This worked for me. I had recently installed an incompatible program and once the references were removed from the .profile, I was able to log in again. – zkent May 01 '14 at 09:09
  • @TerryWang, Same here. I have no idea why though. I don't remember adding that line, so I don't know why it suddenly broke my entire Xorg session. Another reason to hate Ruby... – Cerin Oct 01 '14 at 07:06
  • After hours of debugging the login loop, it ultimately was an error in my ~/.profile. Thank you +1 – Miguel Mota Aug 10 '16 at 06:50
  • I got the login loop for one user, and for that user I found that a script invoked from the .profile had a set -u, and the ~.xession-errors showed XKB_IN_USE: unbound variable. Removing the set -u allowed the login to complete. I did not find which script used XKB_IN_USE , but it was not in the same file as mentioned by BUGID 1452539. – mao Jan 25 '18 at 10:09
  • I think it is fairly good question to ask: did the user edit the ~\.profile before reboot? I didn't have an .xsession-errors at all, but I did forgot a closing bracket in my ~/.profile. Maybe you should adapt the answer to emphasize that the most likely culprit is a syntax error in ~/.profile, and besides, to check for .xsession-errors to further the evidence. – Daniel Dinnyes May 27 '18 at 21:55
  • Thank you so much for sharing this. I spent half the day upgrading graphics drivers and running through kernel logs and then this was the solution. – oldsea Jan 08 '19 at 16:54
  • I also moved unnecessary test from ~/.profile and then "source ~/.profile" -- solved my problem. – atrivedi Feb 27 '19 at 08:34
  • Thank you sooooooooooooooooooooooo much, exact mistake – Geek Guy Oct 02 '19 at 16:50
53

I had a nearly identical problem a few months ago. Switching into a console from the LightDM login screen (Ctrl-Alt-F1), logging in with administrative username and password, and entering the following commands resolved the issue:

sudo mv ~/.Xauthority ~/.Xauthority.backup
sudo service lightdm restart
mblasco
  • 2,287
  • ,Thanks I just type the second command It solved my problem but what this command will do will you plz elaborate – smali Aug 06 '14 at 10:25
  • 15
    This command renames ".Xauthority", which is a file that stores credentials used for authentication of X sessions (basically a cookie), to ".Xauthority.backup". Renaming this file causes xauth to create a new ".Xauthority" file, thereby re-authenticating. – mblasco Aug 11 '14 at 13:53
  • 1
    BRILLIANT. can't thank you enough - worked first time. – whytheq Jun 11 '16 at 20:19
  • I had the this issue 3 times with Ubuntu, Debian and Fedora. This is a gnome issue!!! And we’re now 2023… sigh. So for me this worked, but it doesn’t create a new .Xauthority file after login, why? The file is just nog needed and SHOULD NOT INFLUENCE THE STARTUP BEHAVIOUR :-$ – jaques-sam Apr 07 '23 at 05:40
39

My home folder was full :-( df -h will give you this answer I had to connect through ssh made some space and worked like a flower

ctrl+alt+F1, login as user, free up some space and restart your X server! mostely sudo service sddm restart

Philippe Gachoud
  • 5,900
  • 3
  • 43
  • 50
  • yeah,mine too, my home folder was almost full... 800GB from 1TB... i tried all of other solutions,didnt work... so i transferred 300GB of my files too external hard disk... and it worked ... thanks Philippe:) – Sss Feb 16 '18 at 13:27
  • 1
    For me it was issue with not enough disk space because of huge log files. Pressed Ctrl+Alt+F3 to log into the shell + emptied the log files ==> Now I can log normally – AJN Mar 11 '18 at 14:32
  • 5
    thanks, helped me well! just in case you guys aint want to delete some file you might need try sudo apt-get -y autoremove && sudo apt-get -y clean – AlexOnLinux Jul 04 '18 at 12:17
  • Thanks @Philippe Gacgoud, In my case chromium-browser generated a lot of .pma files at /home/user/.config/chromium/BrowserMetrics, after removing these files I got everything running again. – André M. Faria Mar 10 '21 at 18:43
21

Press Ctrl+ALT+F3. You should be given an unix-style login prompt, so enter your username and password there. From there you should be given a shell (a program that allows you to enter commands, sort of like windows' cmd.exe). Enter these commands and press ENTER (or Return) after writing each one (you will have to enter your password when it shows something like [sudo] password for USERNAME. Note that the password will not show when you are typing it!):

sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y install fglrx

Then reboot your computer using this command:

sudo reboot

See if this works :)


If this does not work, try going back to the 3rd terminal (Ctrl+ALT+F3), login, and enter this command (pressing ENTER after you have typed it):

sudo apt-get -y install lxdm

This will show a DOS-like dialog after a bit. If lxdm is not selected, select it by using the UP and DOWN arrow keys, and press ENTER to accept that selection. Then reboot using the same command as before (sudo reboot).


If this still doesn't work, go back to the 3rd terminal (ALT+F3), login, and enter this command (same procedure):

sudo apt-get -y install lubuntu-desktop

This will install a much lighter desktop environment which should work for now (should enable you to login and use your computer). Once that is done, reboot (sudo reboot), and when you are confronted with the login page, select the Lubuntu environment instead of Ubuntu.

Zanna
  • 70,465
MiJyn
  • 3,336
  • This will not work. X is running he is crashing post login (i think). – coteyr Nov 29 '12 at 17:10
  • 1
    I know, that is because Unity crashes. Probably because 3D does not work. The LXDM solution is for using as little 3D resources as possible so that more resources are freed for Unity. – MiJyn Nov 29 '12 at 17:13
  • I see, could work, I have no idea if lightdm uses "3D" or not. – coteyr Nov 29 '12 at 17:16
  • I think it does... or at least it's seriously heavyweight. – MiJyn Nov 29 '12 at 17:16
  • If lightdm uses 3D then shouldn't it trigger the crash, not after it hands control to unity? – coteyr Nov 29 '12 at 17:18
  • Well just trying to learn myself. Once thing we can agree on is that unity is crashing. – coteyr Nov 29 '12 at 17:19
  • That's what I thought too, but lightdm is a display manager, so it takes care of displaying everything (I think). If it uses 3D, things will be displayed using 3D (at least in my experience). – MiJyn Nov 29 '12 at 17:20
  • Anyways, if it doesn't affect, I added the lubuntu option so that he can at least access his desktop. Not optimal, but it's better than nothing :) – MiJyn Nov 29 '12 at 17:22
  • but when I use my pc I also want to work with a desktop environment I like :) It's installing now, let's hope that Lubuntu can fix it :) – Calvin Wahlers Nov 29 '12 at 17:44
  • @CalvinWahlers, don't worry, I will work with you to fix 3D stuff (that includes unity), but we first need something working to do so :) – MiJyn Nov 29 '12 at 18:08
  • ok, that's really nice :) – Calvin Wahlers Nov 29 '12 at 21:12
  • @CalvinWahlers does lubuntu work? And no problem :D – MiJyn Nov 29 '12 at 22:45
  • no ist doesn't... I've already used gdm, lightdm and lxdm, without any success – Calvin Wahlers Nov 30 '12 at 12:46
  • Even when selecting Lubuntu instead of Ubuntu (the session, not the display manager)? – MiJyn Nov 30 '12 at 16:37
  • down because there's a simpler solution. – SiddharthaRT Dec 05 '12 at 05:05
  • The first part fixed it for me. It also removed some nvidia drivers which were probably causing the issue in the first place and then also fixed my graphics to take on full 2560x1080 resolution. Nice one :) – junkystu Apr 18 '16 at 15:58
  • Simply doing these two things fixed this for me: sudo apt-get update followed by sudo apt-get -f -y dist-upgrade the -f option was required for me due to some conflicts. – Dave Collins Jun 24 '16 at 04:28
20

Faced the same problem today.

The cause was a bit strange to me. xubuntu-desktop was removed, so was ubuntu-desktop. LightDM exited with no error message. Tried lxdm and when I tried to login, it popped up a message saying Xubuntu could not be found.

Reinstalled xubuntu-desktop and it's fixed now. Think apt-get autoremove removed the package.

Eric Carvalho
  • 54,385
sooth
  • 201
  • this autoremove does stupid things. This tool shold never be released (or it needs to be much more tested and improved) as it is so time consuming to fix this irritating problems! Nothing is more frustrating than keep looping in a login screen. luckly ubuntu has other options and I logged via Gnome Metacity session, the only one that worked... – Sergio Abreu Dec 03 '16 at 19:03
13

You might be having problems with LightDM, the login manager that comes in Ubuntu by default. In 12.04 it used to do the same problem you are describing.

You can install GDM, an alternative login manager, to get around this:

At the login screen, press and hold Ctrl+Alt+F2 to go to the terminal. Don't be afraid! Just log in here with your username and password.

Then, type sudo apt-get install gdm. Let it install and type sudo dpkg-reconfigure gdm and follow the prompts to set it as your login manager.

Press Ctrl+Alt+F7 to get back to the login screen which should now look different. Does logging in work? If it does, your problem is solved!

If it doesn't, go back to the fullscreen terminal (again, Ctrl+Alt+F2) and run sudo dpkg-reconfigure lightdm to set LightDM as you login manager again. Now you know that this is a problem with your graphics drivers for sure.

WindowsEscapist
  • 1,483
  • 2
  • 17
  • 42
  • ok, I think I'm not quite such a noob, I know how to enter a terminal there and how to log in :) And I already have installed gdm: doesn't work. lightdm: doesn't work. lxdm: doesn't work... – Calvin Wahlers Nov 29 '12 at 17:53
  • OK. You definitely have a graphics problem then; LightDM can sometimes mirror the problems you're describing (it might help if you said how long the delay is). Sorry I couldn't help. – WindowsEscapist Nov 29 '12 at 19:12
  • Delay means the time between having entered an appearing again? – Calvin Wahlers Nov 29 '12 at 21:52
  • Right. It is like a couple seconds, or more like 30, etc. I can't help you with graphics issues but I'm sure there is someone here that can. Good luck! – WindowsEscapist Nov 29 '12 at 22:56
  • On Ubuntu 14.04 this method gets you a blank screen in place of the login screen. – Luís de Sousa Jan 22 '16 at 14:19
11

Your desktop environment is failing to start (it sounds like). I would start by tring to log in as a different user.

Ctrl+Alt+F1 then login

sudo adduser testing

Once the user has been added ctrl+alt+f7 and try to log in as testing. If you can log in as testing then your unity/gnome configuration is borked and should be reset. This Question covers it. I prefer to mv ~/.config ~/.config.old.

coteyr
  • 18,288
  • 1
    I can't log in as testing... – Calvin Wahlers Nov 29 '12 at 17:30
  • You could have bad libs, try MiJyn's answer. If you can gain access via lubuntu then you have a library issue. – coteyr Nov 29 '12 at 17:32
  • This page gets a lot of traffic, so modern update: adduser testing will not create a Home directory, which will also cause this login loop (at least in Ubuntu 20). You need adduser -m testing – Mars Jun 13 '23 at 02:22
11

This is not a direct answer to your case but its more of a general solution to login loops.

The problem could be as simple as a wrong command put into the .profile file in the home directory. (Since that file get loaded on logon)

To see if that is really the case, press Ctrl Alt F1, and login. Checking the .xsession-errors file in your home directory

~/.xsession-errors

This should give some clues about some problematic command.

10

I've pressed Ctrl+Alt+F3 and logged into the shell. Afterwards with this command:

chown username:username .Xauthority 

Where username is my login name, I've solved the problem.

Basharat Sialvi
  • 24,046
  • 8
  • 62
  • 82
Radu Rădeanu
  • 169,590
9

I have been through this problem multiple times and it has been a different issue each time. One of the following issues could have caused your problem and you could use the command line interface by using Ctrl+Alt+F1 (Replace F1 with F2,F3.... if your tty1 is occupied) to try the following solutions

NVIDIA drivers missing or broken?

  1. Run nvidia-smi to access the NVIDIA system management interface. The output should be something of this sort.
Mon Sep 17 14:58:26 2018       
+-----------------------------------------------------------------------------+ 
| NVIDIA-SMI 390.87                 Driver Version: 390.87                    | 
|-------------------------------+----------------------+----------------------+ 
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC | 
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. | 
|===============================+======================+======================| 
|   0  GeForce GT 720      Off  | 00000000:01:00.0 N/A |               N/A    | 
| 19%   35C    P8    N/A /  N/A |    543MiB /   980MiB |     N/A Default      |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 Not Supported | +-----------------------------------------------------------------------------+

If you're not able to access it, there is probably some issue with your graphic drivers.

  1. In that case, you should be able to find out the name of your graphics card using lspci | grep VGA.
  2. You can find out the compatible drivers for your graphics card using the link.
  3. (Try without this stepand maybe then with this step if there was no success). Remove the existing broken drivers using sudo apt-get purge nvidia*.
  4. Install the drivers using

    sudo add-apt-repository ppa:graphics-drivers

    sudo apt-get update

    sudo apt-get install nvidia-390 (Or whatever the compatible driver is for your graphics card)

  5. Try a restart using systemctl reboot -i and hope your login loop is fixed.

Is your HOME your HOME?

  1. Check the owner of your home directory using ls -l /home
  2. If you don not own your home directory, change it using sudo chown $USER:$USER $HOME
  3. Try a restart using systemctl reboot -i and hope your login loop is fixed.

Do you own your .Xauthority?

  1. Check the owner of your home directory using ls -l ~/.Xauthority
  2. If you don't own your .Xauthority, change it using sudo chown $USER:$USER ~/.Xauthority
  3. If you do, move your .Xauthority file using sudo mv ~/.Xauthority ~/.Xauthority.bak
  4. Try a restart using systemctl reboot -i and hope your login loop is fixed.
  5. You might need to do the same thing on .ICEauthority.

Is your /tmp right?

  1. Run ls -ld /tmp and make sure the permissions are exactly drwxrwxrwt. The output should be of this sort

drwxrwxrwt 27 root root 36864 Sep 17 17:15 /tmp

  1. If not, run sudo chmod a+wt /tmp
  2. Try a restart using systemctl reboot -i and hope your login loop is fixed.

Maybe lightdm is your problem?

  1. Reconfigure your display manager using dpkg-reconfigure lightdm and try out other display managers (gdm3,lightdm,) that are available. Maybe this will you give you enough clues to move forward.
  2. If none of them help,try installing sddm using sudo apt-get install sddm for one final try. reconfigure display to sddm.

If none of the above solutions worked, you can try re-installing ubuntu.

P.S: This is a compilation of answers from the sources I refered to, some from this post as well.

9

Yes I caused a Login Loop on my main Ubuntu 12.10 user and the fix was simple.

Background: Ubuntu 12.10 is installed in VirtualBox running on Windows 7 and uses Unity.

Cause: From the Desktop I Ctrl+Alt+T into terminal mode and then tried to run 'startx' (I was trying to help a friend over the phone late at night...but this was a stupid thing to do). A new blank Unity desktop appeared and everything hung...

Problem:

Forcing VirtualBox to close and then rebooting Ubuntu I got to the login screen but kept looping back to this same screen everytime after entering the password. No errors were displayed. I could login as Guest but I had no Sudo rights and thus no control... However once logged in as Guest I Ctrl+Alt+F3 and got to a terminal login.

I entered my main user name and password and logged in with command mode. Logout took me back to CLI login and Ctrl+Alt+F7 took me back to Guest desktop. So my account still worked. I then added a test user and gave them sudo rights. From the Unity login I could login and logout Test user with no problem. So Unity still worked.

Fix: So my main account was still accessable via CLI and Unity was working for all other accounts. This indicated a configuation problem on my main account. I followed the advice of SiddharthaRT at the top of this post and did chown username:username .Xauthority. This fixed my problem. Thanks !!

dlin
  • 3,830
Dig
  • 331
  • I'm facing the same problem today in 14.04.02 but unfortunately I disabled the guest account. My user and root passwords are not being accepted in any terminal I've tried. Any suggestions? I already went ahead and installed 12.04 alongside thinking I might be able to access my files on the 14.04 side, but no luck – Rich Scriven May 27 '15 at 21:56
  • I have now run into this problem after trying to fix my R instance. Richard, did you manage to fix your problem? – Alex Jun 16 '15 at 02:26
9

I only had to change the permissions of my home folder:

sudo chmod 755 /home/<username>

This can be done by logging in, into a terminal, using your username and password in a shell using CtrlAltF1.

muru
  • 197,895
  • 55
  • 485
  • 740
ffurrer
  • 141
  • 1
  • 5
  • 1
    After trying all, I just ended up that "let me check my user's home directory permission", and found the problem, then I was scrolling down and I see you already posted this as an answer : ) – αғsнιη Jul 28 '16 at 14:24
  • this was my login loop cause as well your answer fixed it +1; I checked /tmp, ctrl+alt+f1-7 did not work for me for some reason, but I could get to root via the grub menu at boot, creating a new user also did not work - it had the loop in the new user too; tried to switch to gdm3, even worse, the screen went black at boot so went back to lightdm; disk was not full; could not check .Xauthority as the home was encrypted;tried openbox xfce all the same; how the home directory permissions were changed to r-x------ not sure, but the loop started after the netbook shut itself down due to low battery – jmarina Feb 04 '22 at 12:08
9

Proprietary Driver Issues

MoKSB State

I was able to log in to TTY using ctrl+alt+F1, but had no internet access seeing as the driver is proprietary as well.

No Xorg issues were apparent.

I decided to remove the packages when I recieved the MokSB failed message telling me that it could NOT change the secure boot settings. The notable part is that it prompted me for a password even though it failed.

Secure Boot

Caution: Do NOT just blindly remove your drivers!

A good test to see if it is a Proprietary Driver issue is to turn OFF Secure Boot and boot Ubuntu and attempt to login. If logging in works, then you now know what you're issue is.

Broadcom Drivers and Nvidia Drivers

I removed nvidia packages

sudo apt-get purge nvidia-*

and then I removed the broadcom packages

sudo apt-get purge bcmwl-kernel-source

and rebooted.

I attempted to login again and success!

I saw my desktop!

I rebooted again. logged in again and everything was set to default.

  • I rebooted into BIOS

  • turned off secure boot (not recommended, need a better solution)

  • booted up ubuntu using grub

  • logged in and installed the downloaded *.deb file for my wifi driver

  • installed it using Software Center

  • and rebooted.

I followed the same procedure for my nvidia drivers seeing as the default video drivers are awful on my card.

Turning Secure Boot On Again

If I turn on Secure Boot again, I see the same issue. Since the drivers are NOT signed, it's not a true Secure Boot and I get locked out.

Personally, I find this to be a very bogus (and annoying) issue.

Alternative Solution?

The most feasible solution I saw was customizing the kernel seeing as I can't simply leave Secure Boot off and turn it On and then Off when I switch OS's. Again, it's just annoying.

UPDATE on Jan 4 2017

According to this article, the Linux Kernel >= 4.6 now officially supports

GeForce GTX 900 series accelerated support in conjunction with signed firmware images.

This should resolve the secure boot issue caused by using the unsigned firmware images.

  • This fixed the login problem as in I could login again, but WARNING sudo apt-get purge nvidia-* somehow (???) also manages to try and reinstall mysql. This seems crazy, but I replicated the behavior. Thankfully it did not delete my files, but when it produced an error it did manage to change configurations. This makes no sense to me, but I replicated the behavior and it asked me to give it a new mysql root password again so this indeed occurs. The graphics issue is super annonying and also strikes me as bogus issue made up by Ubuntu, but on the solution GOOD GRIEF YOU HAVE BEEN WARNED. – Michael Jul 30 '16 at 00:04
  • I had the same issue, and turning off Secure Boot seemed to be the only way to fix it. – Nick Nov 30 '16 at 09:57
  • Couldn't ubuntu log in with low resolution driver and tell user that faced a problem with the driver instead of getting looping ? It is the expected of a really intelligent software... maybe here is a feature request. – Sergio Abreu Dec 03 '16 at 19:12
6
sudo chown $USER:$USER $HOME

was the problem for me.

I had set up a home partition with:

sudo mkdir /home/$USER

but forgot to chown it.

5

I found my /tmp file permission settings were not correct. It had permissions for root only.

This was my own mistake. I forgot that a day earlier, I deleted the /tmp folder with sudo rights and after recreated the folder again with sudo mkdir tmp. Big mistake. I created a /tmp folder with root permissions only.

In the ~/.Xsession-errors file I could see that x11 was not able to write a file in /tmp. After execute these commands from the root account (or Alt+Ctrl+f1) in welcome screen and use the problem account credentials to login) I solved the problem:

sudo chmod 1777 /tmp
sudo chown root:root /tmp

After these, I was able to login to Unity again with the normal account again. So if you have, what looks like a .Xauthority problem, you could try this if nothing else works.

See this thread on Ubuntu Forums

Zanna
  • 70,465
Dirk
  • 51
  • 1
  • 2
5

I got the login loop in connection with an update from Ubuntu 12.04 to 14.04. With gdm I had error messages in ~/.cache/gdm/session.log with entries such as /etc/gdm/Xsession: line 33: mktemp: command not found and after sudo aptitude purge gdm with lightdm I got several similar error messages in ~/.xsession-errors, e.g., usr/sbin/lightdm-session: line 24: mktemp: command not found.

I tried several things. What I believe did eventually resolve the problem for me was this:

I moved my configuration files .profile, .bashrc and .pam_environment to other names and then I managed to login. I suspect that there is a problem in one of them.

  • After installing Ubuntu 18.04 and adding my usual .bashrc, I ran into this problem. Removing the .bashrc fixed it. I assume there was an error that didn't surface in 16.04, or maybe Unity didn't execute the .bashrc on GUI login, but GNOME does. – Nick S Sep 05 '18 at 22:33
4

20.04 and above:

Opening a console

To open a console, you can press Ctrl + Alt + f5 or boot into grub recovery mode.

Method #1 Removing Old Configuration files.

As System 76 support says in their article, you can remove the old configuration files to fix this issue:

  1. Add a new user
sudo adduser test
  1. log in as the new user (test)

  2. If the login worked without any issues then there are problems with the configuration files of the main user.

  3. Backup/remove the old configuration files:

mv ~/.config ~/.config.old
mv ~/.local ~/.local.old
mv ~/.cache ~/.cache.old
mv ~/.nvidia-settings-rc ~/.nvidia-settings-rc.old
mv ~/.nv ~/.nv.old
sudo reboot
  1. If the configuration files are automatically generated then leave this step:
sudo mkdir ~/.config
sudo mkdir ~/.local
sudo mkdir ~/.cache
sudo mkdir ~/.nv
sudo mkdir ~/.nvidia-settings-rc
sudo reboot

Now try logging in with the regular user.


Method #2 Changing permissions of .Xauthority

  1. Identify the permissions of the file by running (run this in your home directory):
ls -lah | grep -i Xauthority
  1. You should see the file listed with the permissions first, followed by the username and group that own it. If you see “root” listed there, you’ve found the source of the problem.

  2. Give proper permissions:

sudo chown username:username .Xauthority

change "username" with your username.


Removing Gnome shell extensions

Sometimes a corrupted gnome-shell extension can also cause this issue. Removing the extensions will help:

sudo rm -r ~/.local/share/gnome-shell/extensions/*

Resetting gnome

Sometimes, there are problems with configuration files, in that case resetting gnome and its applications will help:

sudo dconf reset -f /

Installing correct Nvidia drivers

  1. First, remove all the Nvidia drivers by running:
sudo apt purge nvidia*
  1. Auto install the recommended drivers:
sudo ubuntu-drivers autoinstall
  1. Install the specific drivers for your device:
ubuntu-drivers devices
# identify the drivers needed

sudo apt install nvidia<version>

  1. Try using system76 drivers (optional):
sudo touch /etc/apt/preferences.d/system76-apt-preferences
echo "Package: *
Pin: release o=LP-PPA-system76-dev-stable
Pin-Priority: 1001

Package: * Pin: release o=LP-PPA-system76-dev-pre-stable Pin-Priority: 1001" >> /etc/apt/preferences.d/system76-apt-preferences sudo apt-add-repository -y ppa:system76-dev/stable sudo apt-get update sudo apt install system76-driver-nvidia sudo apt update && sudo apt full-upgrade


Disabling AMD Radeon Drivers

On newer versions of Ubuntu AMD, GPU chips are not well supported, so sometimes it is causing the issue. Turning it off would help:

sudo echo blacklist radeon >> /etc/modprobe.d/blacklist.conf

sudo update-initramfs -c -k all sudo shutdown -r now


Reinstalling display manager

Sometimes the display manager needs some troubleshooting, reinstall it:

sudo apt install --reinstall ubuntu-desktop gdm3 gnome-shell

After that run:

sudo dpkg-reconfigure gdm3

Select the option gdm and press enter.


Changing display managers

You can install a new display manager by the following commands:

sudo apt install lightdm
### If you want sddm 
sudo apt install sddm

Then run:

sudo dpkg-reconfigure <display manager name> # example lightdm



Thanks to System76 support, for letting me use some information (method #1, method #3, and method #4) for letting me use some information from their article.

Error404
  • 7,440
  • I believe adduser test should be adduser -m test . I could not login without a home directory in Ubuntu 20.04 – Mars Jun 13 '23 at 02:25
  • I don't have enough AskUbuntu rep to answer this question, so I'll just say it here--recreating my user with -m allowed me to login (Ubuntu 20.04). – Mars Jun 13 '23 at 02:26
  • Followed the display manager steps and it worked, thank you! – Jessé Catrinck Jan 25 '24 at 16:24
4

I had the same problem after a clean install of Ubuntu 12.10 (but reusing my existing home partition). I tried all of the other answers, but none worked. But I found the clue to my specific problem in the file .xsession-errors in my home directory.

This is how I solved it in my case:

  1. Hit Ctrl+Alt+F1 to open a virtual terminal. Then login with username and password.

  2. Open the file ~/.xsession-errors if it exists (type cat ~/.xsession-errors). In my case, this file contained one single line with an error message:

    /usr/sbin/lightdm-session: 27: .: Can't open /usr/bin/byobu-launch

  3. Now byobu is a command line tool that I use and I have no idea how that ended up in a system file since this was right after a clean install. Byobu is not installed by default, so that might explain the error as it looks for a file (/usr/bin/byobu-launch) that doesn't exist. So in my case I had to install byobu to fix the problem:

    sudo apt-get install byobu

  4. Hit Ctrl+Alt+F7 to go back to the login screen, and login worked fine now.

Of course in your case you might find a different error message in .xsession-errors, which requires a different solution.

dlin
  • 3,830
4

I had a very similar issue where I could log in on the terminal but not on the desktop, my wallpaper from the profile was loaded during login, but after a few seconds it jumped back to the login screen. I checked all file permissions as suggested, they were fine. I tried without a separate home partition and was able to log in to the desktop. After that I checked the settings for the LUKS encrypted home partition, which were also fine (though there were some error messages on the terminal, telling me that the encrypted volume could not be mounted, because it was already mounted).

Then I looked into dmesg, found BTRFS errors related to the filesystem on the LUKS encrypted home partition (yep, I'm mixing LUKS and BTRFS), tried to actually write to the filesystem and found that it gave me I/O errors. So I had to repair the filesystem or create a new one and restore from backup.

Long story short: Look at dmesg and actually try to write to the filesystem that seems to be writable.

LiveWireBT
  • 28,763
3

Solved using these commands:

 sudo apt purge gdm3
 sudo reboot
 sudo apt install gdm3
 sudo service gdm start
0x8BADF00D
  • 736
  • 7
  • 12
3

This could also be because of a special combination of settings:

  • Encrypted /home/$USER
  • $USER in nopasswdlogin group

lightdm will try to log you in, but can't access any files so you get the described symptoms.

To fix this, remove $USER from the group:

sudo gpasswd -d $USER nopasswdlogin
3

I experienced the same problem and the cause in my case was that I tried to add something to the /etc/environment file and whatever I added seemed to not want me to log in after I restarted.

Solution:

When at the login screen press CTRL + ALT + F2. Login with admin username and password and edit the /etc/environment file and remove what changes you made to it.

In the terminal, you can run the following command use nano to edit the file:

sudo nano /etc/environment

Press CTRL + o and then press ENTER to save the file. Press CTRL + x to exit nano.

Once you have edited and saved the file, simply hit CTRL + ALT + F2 to go back to the GUI login screen and you should be able to log on.

mchid
  • 43,546
  • 8
  • 97
  • 150
Jonny
  • 439
  • 2
  • 5
  • 15
3

I had to deal with the same problem. Unfortunately in my case it was not resolved by simply changing permissions so my contribution will be to try to create a guide from the simple to the more complex steps. Hopefully your uses will be resolved with the simple ones.

Note: replace <username> with your username.

Assumptions: Nvidia Graphic Card, lightdm


Access To Terminal

To open a new terminal simply use (and then login with your credentials):

Ctrl+Alt+F1

Check the owned/group/permissions of your home directory files

cd ~<username>
ls -lah

Fix the owner and group of .Xauthority and /tmp

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

Check if there is still a problem by restarting lightdm

sudo service lightdm restart

Reconfigure lightdm

dpkg-reconfigure lightdm
sudo service lightdm restart

If you wish to see possible errors from the system

tail -n 50 /var/log/Xorg.0.log # if you want to see the last 50 errors
tail -f /var/log/Xorg.0.log    # if you want to be able to see all new errors live

Relevant log files:

/var/log/Xorg.0.log
/var/log/lightdm/lightdm.log

As a last resort, which is what I did, reinstall the graphic card drivers. Nvidia simply does not work nice with Ubuntu.

Stanislav
  • 223
  • 1
  • 9
3

I had to remove NVIDIA drivers to get in, as in (replace nvidia-current with nvidia-340 or whatever your number is).

Revert back to Nouveau drivers

Then I had a buggy UNITY frame. I had to follow the steps showed here to fix them:

https://askubuntu.com/a/290376/275142

Evin1_
  • 249
3

This happened to me when I switched off the computer while it was still finishing upgrading to the latest kernel images. I did CTRL-ALT F1, logged in, then sudo apt-get update and sudo apt-get dist-upgrade and let it finish to setup.

After rebooting, I was able to login into the destkop again.

2

If you recently installed indicator-multiload, uninstall it.

This problem happened to me after I installed indicator-multiload, so uninstalling it fixed the problem.

Eliah Kagan
  • 117,780
2

Change to another login screen.

Ctrl+Alt+F2 to open a terminal.

Ctrl+Alt+F7 to go back to the graphic mode.

Type sudo dpkg-reconfigure gdm

In a graphic screen, select gdm and OK.

Type sudo reboot

Radu Rădeanu
  • 169,590
2

Just in case changing the access privileges for the files .Xauthority and .IDEauthority with the chown command did not work for you:

This solution applies to those who besides having had to change access privileges for the above mentioned files cannot use commands as they used to, i.e. the shell does not find the commands. (This is the reason, why the login command cannot be executed either.)

Type echo $SHELL into your terminal. If you get back /bin/bash, use export PATH=$PATH:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin to temporarily be able to use commands.

Then open your .profile file, located in your home directory ~, i.e. /home/yourusername with sudo gedit ~/.profile and add the missing paths to PATH, so that it looks like this:

PATH=/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin

Now reboot your system so that the changes to the environmental variable PATH take effect.

(If commands are not recognized by your shell, you could also use the equivalent paths to the executables of the commands, e.g., instead of sudo gedit ~/.profile type /usr/bin/sudo /usr/bin/gedit ~/.profile. The shell tells you the directory to use, i.e. command not found, but the command your are trying to use can be found in /path/to/command's/directory - could be any of the paths you see above.)

Sekin
  • 31
  • This solution actually worked for me, the issue was I had made some changes in "/etc/environment/" file that caused login loop. But none of my commands were working even in safe mode, so your trick to temporarily enabling commands worked and I was able to access my system again. Thanks and +1 for the solution – Saqib Sep 25 '19 at 19:15
2

May you are affected by Bug #1240336 where different permissions are gone after release upgrade.

Other side effects

  • no guest login
  • Synaptic not starting from menu

I get login to work when I put the user into the video group or after running sudo chmod a+rw /dev/dri/* in a terminal.

But:

  • no sound
  • Logout from user menu not working
  • running /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 gives: polkit-gnome-authentication-agent-1:5805): polkit-gnome-1-WARNING **: Unable to determine the session we are in: No session for pid 5805

Solution

Run sudo pam-auth-update --force in terminal. This solved the described problems in my cases.

Zanna
  • 70,465
uzhoasit
  • 1,633
2

For me configuration of some packages was off, so running (after ctrl + alt + F3):

sudo dpkg --configure -a

fixed the problem.

Akavall
  • 637
  • 2
  • 10
  • 27
  • This can happen also if you do a Ubuntu version upgrade, and there is an interactive prompt that dpkg misses during non-interactive install. – meawoppl Oct 30 '20 at 15:29
1

After reading James answer , I realized I had changed the user password by logging in as root. I knew the old password, so I logged in as root again ( to login as root press ctrl+alt+F3 give the username as root and and enter your root password) and changed the password for that user to old one by below command

passwd <username>

Now change the password to old one , press ctrl+alt+F7 and login normally. This solution works only if you have encrypted home directory issue and incase you had changed password using root.

rahul
  • 233
1

I had a similar issue recently. Ubuntu made some updates and i got this login-loop that seemed to be related to lightdm.

I finally managed to solve the issue after trying several things.

I suspect amdgpu to be the reason of failure but because i dont know for sure, i am going to post everything, that i tried:

Taken from my original question on askubuntu: See here

  1. uninstall amdgpu-pro (amdgpu-pro-uninstall)
  2. install the open source driver (see here). I also installed all those *hwe* packages.
  3. reinstall and reconfigure lightdm, ubuntu-dektop, unity

At this point - after rebooting - my keyboard would not respond anymore, so i booted into recovery mode and selected the option to repair broken packages, which worked and i could use my keyboard again.

Unfortunately the login still would not work. Additionally i added my user to the lightdm group, but i doubt that is of any importance.

Then i found other similar issues and tried the following steps:

# as root
add-apt-repository ppa:paulo-miguel-dias/pkppa
apt-get update
apt-get upgrade
reboot

Still no success so far, so i decieded to try another upgrade method

# as root
apt full-upgrade
reboot

And then i was able to login again.

My personal conclusion

It seems the problem exists within the amdgpu driver and ubuntu will not be able to install a working driver unless you add the ppa mentioned above. It says to work only with Ubuntu 18.04 but i tried it anyway and it worked for now.

1

Same problem on multiple RPIs (version 2B and 3). Solution:

  • check the .xsession-errors file: cat ~/.xsession-errors. Mine showed:

Xsession: X session started for pi at ****

Xsession: unable to start X session --- no "/home/pi/.xsession" file, no "/home/pi/.Xsession" file, no session managers, no window managers, and no terminal emulators found; aborting.

  • to solve this reinstall the following packages:
sudo apt-get install xserver-xorg-core xserver-xorg-input-all \
xserver-xorg-video-fbdev libx11-6 x11-common \
x11-utils x11-xkb-utils x11-xserver-utils xterm lightdm openbox

Source: https://www.raspberrypi.org/forums/viewtopic.php?t=154190

fyi: I used the RPIs before with auto-login and non-gui mode. Thus, I reinstalled lightdm and ended up at the login loop problem after switching to auto-login GUI mode (raspi-config).

hb0
  • 221
1

GNOME-Shell extensions installed to user's profile were apparently causing the login-loop in case of Bionic Beaver installation here. User is able to again successfully login to its graphical environment not until removal of all of GNOME-Shell extensions installed to user profile. Found then removed from Bash had been ext-helper@amanda.darkdna.net and workspace-grid@mathematical.coffee.gmail.com.

I believe to had found that track by examining systemd journal, there was also a signal in web addressing Gnome shell extensions in this or close context.

Problems started to occur after installation of security and basic updates in calender week #3 of 2019. Actually no reconfiguration at system level was conducted by user that time.

Now two system-level GNOME-extensions are left because no way was found to uninstall them too. However these are set to disabled. Extensions' main switch is also put to OFF. Maybe middle or long term I will try to use extensions again, however by progressing with caution and in small steps.

Consequently none of hints found here could help as the underlying points were OK, e.g. ~/.XAuthority, ~/.ICEAuthority, /tmp directory, Nvidia stack. lightdm-based approach was undesired as in this case Ubuntu 18.04 is used which does not use lightdm as default. It is installation running in VmWare-hypervisor so the emulated graphic card is not from Nvidia. Those hints could not be applied too nor help. I was also unable to find in ~/xsession-errors directive hints.

I found Rmano's approach interesting and applied that which in consequence uncovered few other interesting points, these will be raised in new Questions. Also Rmano's hint contributed to success in this case. Thank you.

Fifi Cek
  • 309
  • 3
    Thank you for giving an account of what you experienced ... but I don't see how it answers the original question. – PerlDuck Jan 27 '19 at 11:31
  • My Question raised one week ago or so was put by other members to duplicate of this one. You see zero commonalities? – Fifi Cek Jan 27 '19 at 12:36
1

If you cannot log in, the disk/partition of your home folder might be full.

To find out if your disk/partition is full: press Ctrl + Alt + F3, login and type df. You get information on the used disk space.

1

I'm sure nobody except someone with an extreme case of the issue will see this, but if you do... maybe this will help! :)

Adding to the current answers - and building off of them to a large extent, I have once or twice had the problem that files other than .Xauthority are owned by root for some reason. This can create login loops, problems with secondary monitors, and a host of other issues. To locate suspect files, run:

user@hostname:~$ find -user root

From there, you kind of have to fish around in the output and see if you can't locate something that looks unusual.

As a side note, it also shows if .Xauthority is owned by root...

anonymous2
  • 4,298
1

In my case, this was caused by a newly installed software through the Software center (or whatever its called) called Brightness Control (Xrandr). So I logged into Ubuntu using Unity from the logging window and then I opened up the Software Center to uninstall it. After rebooting I could log into Ubuntu (Gnome).

blue_chip
  • 161
1

There is another possible cause for this problem not covered in the other answers:

If your homefolder is encrypted and you changed the user password without changing the encryption password.

In this case when you login, your password will not be the same as the encryption password and your home folder cannot be loaded. As a result, your .Xauthority file will not be able to be loaded, and you won't even find it if you try to as suggested in @SiddharthaRT's and many others' answers.

(As a hint if you don't remember if your home folder was encrypted, if you do ls -lA you should see some files with "encrypt" in their name and a folder called .Private if your home folder was encrypted.)

You have two options:

  1. The easiest is to reinstate your old user password, using

    sudo passwd user
    

    where user is your username. Then you'll be able to login as normal again. However, if you changed your user password you probably have a reason for this, so the 2nd option is better.

  2. Rewrap (i.e. change) your encryption password, as explained here. Basically, to do this (assuming you have kept your new user password), mount your encrypted home folder as follows

    ecryptfs-mount-private
    

    and then set the encryption password to the new password with

    ecryptfs-rewrap-passphrase ~/.ecryptfs/wrapped-passphrase
    

    Then everyting should be mounted as normal again.

Lu Kas
  • 197
1

I had the same problem after I upgraded to 12.10.Then I came here from Google. I created another user and I could login.

As I don't use Unity, I uninstalled lighdm. After reboot, I could login. You can try that.

Good luck!

1

I have been experiencing the very same problem a couple of times every week and have tried most of solutions given here but the only way I can log back in is by restarting lightdm.

sudo service lightdm restart.

The funny thing is that even after I restrat lightdm, it does not log in on the first attempt but only on my second attempt even though I am entering the right password. I realised this a few weeks ago and I have verified this a few times, making sure that I am not accidentally keying in my password wrong. I am now certain that it does not log me in the first time after restarting lightdm but only on the second attempt!

eshwar
  • 808
  • Today I got a clue about my problem. I have an external monitor connected to my laptop. When I got into the login loop I decided to somehow get it working with restarting lightdm. From a bug report in launchpad I got an idea that it could be due to some issue in recognising my external monitor. So, I disconnected the monitor, dropped to tty1 and back and the login worked the first time! Not the second time like when I restarted lightdm. This is better but there has to be a solution which does not require this. – eshwar Jul 18 '14 at 10:17
1

If the other questions do not lead to a solution, my suggestion is to try to follow these steps:

  1. Login in character mode with a VC (Virtual Console). That is, Ctrl Alt F1 and your username/password login. Let's call this user original.

  2. Create a new user. You can use for example:

    adduser newuser --group sudo
    

    to add a new administrative user (that is, a user that can do sudo).

  3. Try to login as newuser. If it works, you now that the problem is in the specific setup of original user. Otherwise, stop reading here --- the problem is at system level and you'll probably need to reinstall something of the graphic stack.

  4. Now you can try to search what happened. Compare hidden files in ~original and ~newuser and try to find mismatches. Especially you should search for files not owned by you:

    find . \! -user original
    

    and files that are not writable to you (there will be more of them, especially in caches):

    find . \! -perm -u=w
    
  5. You can move suspicious files to a backup (sudo mv whatever whatever-backup) and try to login again.

  6. Files in /tmp and /var that can be sensible to this problem should be deleted by a reboot --- but sometime there is some remnant over there, too.

As a last resort, you can backup the important info of original (not all the home dir! or you'll propagate the problem), and delete and recreate it, although it is better to be able to find where the problem is.

Rmano
  • 31,947
1

In my case the problem was caused by wrong permissions on my home directory.

1: Boot from a live media (or different linux distro installed on the same system) and open a terminal with Ctrl-Alt-T

2: Make a temporary mount point and Mount the partition that contains your /home (in my case it was /dev/sda6)

sudo mkdir /mnt/sda6 sudo mount /dev/sda6 /mnt/sda6

3: check permissions

sudo ls - la /mount/sda6/

you should see an entry username` where username is your username

From this point forward we will use the username tvbox (change this to your username)

You should see something like this:

drwxr-x--- 67 tvbox tvbox 12288 May 1 07:00 tvbox

This indicates that tvbox is a directory and the owner has the required read, write an execute permissions.

4: correct permissions if incorrect.

If the above is incorrect in any way we need to correct it.

If data was moved by root you will see root root rather than tvbox tvbox (owners name owners group) This could be referred to as the "root cause" ;-)

To fix this issue the command `sudo chown -R tvbox:tvbox /mount/sda6/tvbox

If somehow the other permissions aren't right you will need to modify them with sudo chmod +rwx tvbox adding read write and execute permissions.(the execute bit on a directory allows you to traverse it.)

5: reboot the problem OS

6: login

If this doesn't resolve your problem refer to the many other quality answers here.

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
  • It seems that Elder Geek's issue was caused by a user ID mismatch.This fixed it for me
      sudo chown -R NEWUSER:NEWUSER *
      sudo chown -R NEWUSER:NEWUSER .*   # to include hidden files and directories
    
    

    For more details see https://askubuntu.com/questions/1230434/ubuntu-20-04-can-t-login-after-upgrade/1234771#1234771

    – Christians May 03 '20 at 13:52
1

For me following worked. Type ctrl + alt + F1 and login with your username at command prompt.

user@dell$ ls -l ~/.ICEauthority
-rw------- root root 3668 May 28 09:28 /home/user/.ICEauthority
user@dell$ sudo chmod 777 ~/.ICEauthority
password:
user@dell$ ls -l ~/.ICEauthority
-rwxrwxrwx root root 3668 May 28 09:28 /home/user/.ICEauthority

ctrl + alt + F7 and login worked.

iammilind
  • 2,247
1

I've experienced this issue on a Xenial installed on a usb key, mounted on a HD-less laptop, running unity and gnome-flashback. Tried about every workaround in here without success, then remembered that some days ago, while in chroot and using qemu, if I choose gnome-flashback-compiz I got the issue while with unity I didn't. Tried with gnome-flashback-metacity and it worked.

In this case too, it doesn't work with gnome-flashback-compiz but with gnome-flashback-metacity and with unity it worked.

Silvia

Silvia
  • 538
  • 2
  • 9
1

In my case, my user folder somehow got chown'ed by root! The answer lies in .Xauthority and other files in your home folder; if user config data can't be opened read/write, lightdm will fail.

I simply ctrl+f1, logged in, then sudo chown /home/<userdir>, then sudo service lightdm restart (may not be necessary), and then I was able to get back in.

Some diagnostic messages would be more useful, but such is life with free software.

M K
  • 71
1

Regarding Gnome Users:

I tried all of these optionals to no avail. Likely due to using Gnome as my preferred UI.

After looking at Sooth's Answer I was able to get it to login with the ubuntu and xubuntu GUI, so his post helped a spark in my brain.

I didn't see anything related to Gnome, so I looked up some instections and followed this guide from OMG Ubuntu for Gnome 3.2 on Ubuntu 16.04.

I had Gnome working flawlessly so I have no clue what went wrong one day. It's a bit of a download and upgrades but this worked for me with Gnome and I'm happy without the login loop of death!

JREAM
  • 309
  • 1
  • 4
  • 12
1

I found another way to cause a login loop not covered by any of these answers, yay me!

I had a script to set up my dual monitors that was referenced in /etc/lightdm/lightdm.conf as a session-setup-script. When I went to a single monitor config, I deleted the script, but did not remove the reference. Next time I booted up - login loop.

Examining the logfile in /var/log/lightdm/lightdm.log I found an explicit error message telling me the script was not found and therefore lightdm failed to start. Commenting out the reference in lightdm.conf fixed it.

Organic Marble
  • 23,641
  • 15
  • 70
  • 122
0

I got into the login loop by running the software updater for 18.04 on Jan 30 2019. It was very hard to get into terminal mode per Ctrl+Alt+F1 or F2 or F3, succeeding typically only after a number of reboots. Getting into terminal mode per Ctrl+Alt+F3 became reliable only after installing lightdm and switching to that as suggested in the popular answer above. The other standard recipes (check ownership of .Xauthority and .ICEauthority and permissions of /tmp) were in order and mucking with the nvidia driver didn't help. After much googling I found Khalil Laleh's suggestion at Ubuntu 18.04 Login window loop to check your gnome extensions. Bingo! In my case Zakkak's workspace grid = 'workspace-grid@mathematical.coffee.gmail.com' in directory ~/.local/share/gnome-shell/extensions needed to be removed to make Ubuntu finally start up, and then reinstallation from https://extensions.gnome.org restored my workspace layout.

slava
  • 3,887
0

I ran into a similar problem on both my office linux installation and home machine. I installed a program which required compilation and the executable file was in the bin directory of the program's folder. I exported the PATH, but on booting the normal /bin /usr/bin ... was replaced by my mistake, so the path to bin was only my programs/bin folder. Hence it went to login loop

Once I removed my added path, it started booting normally.

Another user -xpioneer had pointed out the problem. I am just reproducing below--

"There is one more possible reason . If you mess up the /etc/environment file then also it can happen. To fix . do ctrl+alt_+F3 and login to session. check if you can run any shell command. if not then that's the problem. – " xpioneer Dec 7, 2019 at 4:28

0

In my case, I looked at ~/.xsession-errors and found the problem was actually at ~/.profile with a missing binary which wasn't needed anymore.

I deleted the line and restarted lightdm with sudo systemctl restart lightdm.service and it worked.