Are you trying to login remotely? What did you do to try to enable X11 forwarding?
–
izxMay 19 '12 at 21:40

Does this only happen when trying to log in remotely? Or are you having this problem logging in locally as well?
–
Eliah KaganMar 27 '13 at 1:07

Check your .xsession-errors in your home directory, I found an error over there, fixed it, then I can login from desktop. I did try to change the permission and ownership of .Xauthority but it doesn't help in my case.
–
user288195Jun 3 '14 at 23:25

9 Answers
9

I haven't tried to enable X11Forwarding, but I used to have the same problem. You can fix this in a few steps:

When you get to the graphical login screen, hit Ctrl+Alt+F2, thus you get to a textual login.

Put in your name and password (password is not displayed when you type, neither as stars or bullets).

Type sudo apt-get install gdm and hit enter, give your password and wait to get a line ending with a dollar sign again.

Type sudo dpkg-reconfigure gdm.

Hit Enter at the first screen.

Select gdm in the list you get in the second screen with the arrow keys.

Hit the Tab button (above the caps lock one). Now you see the word Ok highlighted. Hit Enter.

Type sudo reboot and hit enter. You'll get another graphical login screen, but you'll be able to log in!

P.S.:

If you are used to running some programs like ifconfig or others which are administrative ones from a terminal emulator (e.g. gnome-terminal) you'd better add a line like PATH="$PATH:/sbin:/usr/sbin" at the end of the .bashrc file in your home directory. You can do it with echo 'PATH="$PATH:/sbin:/usr/sbin"' >> ~/.bashrc.

If you want to change back to the other graphical login screen from time to time and see if it was bug-fixed and it works again you can run sudo dpkg-reconfigure gdm and select lightdm and reboot (doesn't look like it works if you just run sudo pkill X).

I encountered the same issue after installing package vnc4server in Ubuntu 12.10. (Maybe it sets up X11 forwarding, not sure.) I found that in my home directory, files .Xauthority, .bash_history and folder .vnc were all owned by user root and group root. Changing them (and all files underneath .vnc) to be owned by my own user with the chown command allowed me to login (I rebooted first).

To make these corrections, either ssh into the box from elsewhere or switch to text console with Ctrl+Alt+F2.

This can happen if there is an error in your .bashrc or .profile file. From the graphical login screen hit Ctrl+Alt+F2 and login from there. Fix any errors that you see printed to the console. Type: sudo reboot