I could not log into my laptop (running on Ubuntu) yesterday. Every time I entered my password — a password I haven’t changed in years — I was returned to the same login screen all over again! But I could log into a console by pressing CTRL+ALT+F1, so it was definitely not a typo-in-the-password error. Since I always have a second user account on my PCs, it was also easy for me to verify that I could log in (in desktop/graphical mode) as a different user without any difficulty.
Well, those were the symptoms.
The cause: I had issued this command:
sudo startx, while logged into the PC in text mode just moments before I had this problem for the very first time. Absent-mindedly issuing this and other commands (as root) had caused
.Xauthority and a couple of other files in my HOME folder to be owned by root!
The solution is to log into one of the other consoles, by pressing CTRL+ALT+F1, for example, and simply modifying all the files in my HOME directory with the
chown command. If my Linux user account name was
mememe, for example:
cd sudo chown mememe.mememe .Xauthority sudo chown mememe.mememe *
That fixed it for me. I hope it fixes it for you too.