I am logged out immediately after logging in

I don't know if it would be exactly the same case, but this happened to me because somehow I corrupted the .Xautority file in my home. I think it's something related with remote access to the X server.

Log into a tty (Control+Alt+F6) and after typing your username and password:

sudo rm -v .Xauthority

The .Xauthority file is in /home/, which is where the terminal's default working path also usually is. If you use a tty to sign in as one user to delete another's .Xauthority file, make sure you've cd'd to the right directory first.

Then restart lightdm with:

sudo service lightdm restart

The sistem will recreate the .Xautority file.


For me the immediately logout problem was caused by an error in ~/.profile. I am using 13.10. The (approximate) solution is found here or here. You can change or delete the file causing problems by pressing ctrl + alt + F6 and logging in that way.


What worked for me was reestablishing owner and group of the user's home directory.

In recovery mode (or CTRL+ALT+F6 at the login window):

sudo chown -R youruser:yourgroup /home/youruser

In many cases yourgroup = youruser.

(CTRL+ALT+F7 -> back to login window)