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