Solving ubuntu infinite log in loop

I use Ubuntu 12.04 LTS on two of my machines. Recently there was an Nvdia driver update that caused both machines to stop booting. After trying different solutions I found on the web, I ended with a different problem which I wasn't sure was related to the Nvidia card anymore. Every time I would enter my credentials, the screen turn black for a second then come back to the login screen.

First of all if your machine refuses to even take you to the log in screen, there is still a way to log in to it. When you get to an error page and your machine stops, press CTRL + ALT + F1 to get to the first terminal screen. From there you can enter your credentials and log in into the command line shell. To go back to the graphical user interface, press CTRL + ALT + F7.

Nvidia driver solution

I did not pay attention to which version of the driver I installed caused problems in the first place. But the the solution was to remove every driver and reinstall only the most current.

The command to purge them is:

sudo apt-get purge nvidia-*

The nvidia-* part is to select all drivers that starts with nvidia-. Here is the command to install the most current one:

sudo apt-get install nvidia-current

Infinite log in loop solution

When I was still trying to debug the graphic card problem, I ran multiple commands using as the root user (probably by using sudo startx). Along the way I changed the owner of a very important file .Xauthority by mistake. It was changed to root:root. So every time I enter my credentials to log in, it tries to access that file and gets a permission denied and I am redirected back to the log in screen.

The solution is simple. The file is located under the current user's home directory. So all you will have to do is change the owner of the file to the user's and then try to log in.

sudo chown <username>.<username> .Xauthority

Your computer should log in correctly now.

What is .Xauthority

According to this answer on askubuntu:

The .Xauthority (not .xAuthority) file can be found in each user home directory and is used to store credentials in cookies used by xauth for authentication of X sessions. Once an X session is started, the cookie is used to authenticate connections to that specific display. You can find more info on X authentication and X authority in the xauth man pages (type man xauth in a terminal).


Boby :

Thanx a Lottt budddy. Was trying to find the solution for ages...finally something worked! :)

Ibrahim Diallo :

Glad I could help Boby. Although I was having this problem on Ubuntu 12.04, the same issue happens with newer versions, so it is still relevant.

Rafael :

I love you guy! Thanks, very much!

Ibrahim Diallo :

Glad it was helpful to you Rafael :)

TommyLift :

Worked for Zorin 11 as well. Thank you

Gregor :

I just installed Ubuntu 14.04 using the option to format the hard-drive, so there should be nothing interfering.

I got the old laptop from a friend of a friend, it had a broken Vista installation on it is called emachines G620 and has a nvidia sticker on it. I don't know more about the laptop than that.

So after installing I immediately get to this login loop, so I canĀ“t get in to get the wifi working or anything. I did reinstall the whole thing 3 times already and gave up. Also I tried running ubuntu from the DVD, but same problem with the login loop.

I guess the nvidia driver could be the problem, but how do I install the new driver without access to the internet?

Ibrahim :

Hi Gregor

You don't need to install the driver right away. Just do the purge just in case it is installed by default.

sudo apt-get purge nvidia-*

Restart, then try to login to your computer. If you still have the loop problem, then press CTRL + ALT + F1 this should take you to a terminal window where you can log in.

Look for the file .Xauthority it should be in your user home folder (cd ~/)

run the command:

ls -lah 

and you should see who owns the file. The goal is to have your username be the own. If it's not, then set the user to yours like I described on the blog post.

Hopefully this will solve your problem. Let me know.

Good luck!

Let's hear your thoughts

For my eyes only