# Ubuntu gets stuck in a Login Loop

My problem: As you can guess my Ubuntu is stuck in a login loop when trying to enter my desktop. Means the screen gets black and soon after that the login screen comes back. I'm a Ubuntu Newbie so if there's any answer please explain in a simply understandable language.

I've already read that the problem might be caused by an error depending on the graphics, so I post my graphics to:

-
Look in ~/.xsession-errors; there might be a clue there. –  offby1 Apr 21 '12 at 23:09
Check out my answer in the end. –  SiddharthaRT Nov 29 '12 at 22:55
@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 2: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

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

Now run ls -lah. If in the output 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.

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. dpkg-reconfigure lightdm
2. or uninstall, reinstall it.

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

-
I've same problem, chown username:username .Xauthority helped. But, anyone has an explanation? –  ts01 Jan 23 '13 at 8: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
I did delete the /tmp folder manually I probably was not a good idea for gdm. –  Elzo Valugi Feb 11 '13 at 17: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 8:51
+1 - Although I had to do this for both .Xauthority and .ICEauthority –  Aust Jan 17 '14 at 16:00

I encountered this exact problem and non 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.

-
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. –  pthurmond Jun 6 '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 7 '13 at 15:57
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 7 '13 at 2:58
This solved my problem - failing line in ~/.profile –  Joshua Nov 9 '13 at 1:39
+1 - Thanks for mentioning .xsession-errors –  Aust Jan 17 '14 at 15:59

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

-
,Thanks I just type the second command It solved my problem but what this command will do will you plz elaborate –  ali786 Aug 6 '14 at 10:25
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

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.

-

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:

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 and type sudo dpkg-reconfigure lightdm to set LigthDM as you login manager again. Now you know that this is a problem with your graphics drivers for sure.

-
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

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 !!

-

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.

-

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

-
I don't think thiss will work, he is having problems after gdm/lightdm –  coteyr Nov 29 '12 at 17:09
No, the lightDM loop does actually happen like this (although it depends on the length of the black screen) –  WindowsEscapist Nov 29 '12 at 17:20
until now, nothing really helps :( i selected gdm but now there's only the ubuntu 12.10 wallpaper, nothing else –  Calvin Wahlers Nov 29 '12 at 17:22
Probably I should add that the last time I used Ubuntu firefox told me to restart it... it crashed. LibreOffice also did. Then I rebootet and since that moment yesterday it doesn't work. –  Calvin Wahlers Nov 29 '12 at 18:29

I found my /tmp file chmod settings were not correct. It was chmod to 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.

-

Yeah, press 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 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 (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.

-
This will not work. X is running he is crashing post login (i think). –  coteyr Nov 29 '12 at 17:10
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

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!

-

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:

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.

-

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

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.

-
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 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.

-

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!

-
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

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.

-

## protected by Community♦Jun 26 '13 at 13:55

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.