Today I restarted Ubuntu 12.04, after installing some packages and having updated firefox. When I came in the login screen, I typed my password. After about one second processing, the screen blacked out and returned to the login screen. It gave no errors (like invalid password).

I read something about lightdm causing this issue, so I tried to install gdm in TTY. When I tried to do this, TTY gave me an 'incorrect password (or login)' error. I am very sure my password was correct and I even tried ticking it in the command section so I could rule out changes in the keyboard layout.

I would be very thankful if someone could help me out of this problem since I am now unable to use Ubuntu and similar questions won't solve my problem (since i can't get in TTY altogether).

Edit: I forgot to tell that 2D login and guest login don't work either. I've tried to use mv ~/.Xauthority ~/.Xauthority.old, which didn't work (the tty didn't give a reaction and it didn't resolve the problem).

I also tried to install gdm (to stop using lightdm) using sudo apt-get install gdm and it responded with:

sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner
sudo: fatal error, unable to load plugins

other than this, I haven't tried anything yet.

Edit(2): I tried the command sudo rm ./.Xauthority, which gave the same error as above. Do I need to reïnstall (or retrieve a backup of) my system or can it be saved?

Edit(3): I solved the sudo problem (thanks Shantanu!). I needed to change ownership of several (sudo-related) files. I used pkexec to change ownership using the terminal. I now realize that this shift in ownership may be the cause of my loginloop problem. sudo does work now, so I'll try some other commands. I would be thankful if someone can offer me help on this matter!

  • similar questions won't solve my problem - if you have tried other solutions, then please mention everything you've tried. You say tty gives you a wrong password. Is this when logging in the virtual terminal? Keep in mind that it first asks for your username, and then password, and that the username is case sensitive. Or have you already logged in, but you're getting an incorrect password when trying to install gdm? When you're logged in, do mv ~/.Xauthority ~/.Xauthority.old, and then try logging into lightdm again.
    – Alaa Ali
    Jun 29 '13 at 11:53
  • Other solutions I wanted to use (because they looked relevant) all included using TTY, so that quickly became a bottleneck for me. If you mean with the virtual terminal the 'control+alt+f1' combination, then you are right. I didn't know I needed to input my username in the beginning either, I'll try that now, thanks! I'll update when I tried your solution.
    – Michael
    Jun 29 '13 at 12:11
  • @Michael fix the sudo permission problem first askubuntu.com/questions/143554/…
    – shantanu
    Jun 29 '13 at 18:11
  • use Clt+Alt+F1 for terminal mode
    – shantanu
    Jun 29 '13 at 18:12

I had a similar problem running Kubuntu 12.04 for a long time: The login screen appeared as normal, but logging in would not take me to a plasma desktop, but rather back to the login screen. I assume the problem works about the same way for Ubuntu with gdm as it did for me using kdm.

As a temporary solution, I was able to get to a proper desktop environment by entering:

sudo service kdm stop

from a tty console, which I escaped to with ctrl+alt+f3 from the login screen.

Suspecting a permissions issue with .Xauthority and or my /tmp/ directory (as per many other answers to this same question), I ran:

ls -la ~/.Xauthority

and verified its owners were set to username username and not root root, and ran

ls -ld /tmp

and ensured its permissions read as drwxrwxrwt. I also tried removing the .Xauthority file altogether, hoping it would be regenerated properly upon next login, but this didn't work for me (others seem to have had success trying this, however).

Next I checked my ~/.profile for extraneous lines, and read through my .xsession-errors file for clues to no avail.

What eventually worked for me was removing my ~/.dmrc file.

From https://help.ubuntu.com/community/dmrcErrors:

"The .dmrc is an initialization file which the system checks during session login. Specifically, gnome checks the file for any specific language or session information it hasn't located elsewhere. While often the file is blank except for the basic header data, it may contain a specific language to use at session startup."

This file must have 644 permissions to work properly (EDIT: The above link actually gives a few other permissions that will work besides 644, but 644 is the explicitly given permission to set), so before removing it verify that

ls -la ~/.dmrc

yields the permissions drwxr-xr-x 143 user user, and if not try using

chmod 644 /home/username/.dmrc

If none of the above solutions worked, try backing up and removing this file with:

cp /home/username/.dmrc /home/username/.dmrc.backup
rm /home/username/.dmrc

Upon next login, a new .dmrc file will be generated and configured correctly, and in my case I was finally able to log in properly without escaping to tty, killing kdm, and starting x manually.

NOTE: I suspect the root cause of this came when the partition my home folder was on filled up during a session, which caused a whole slew of other issues with configuration files not being written that needed to be written. The infinite login loop problem started immediately after that, and I noticed that the .dmrc file had a size of 0, rather than containing:


as it does now in the fully functioning condition. It seems from the above quote that this file is read on login, and maybe my login loop occurred because Kubuntu didn't know how to handle an empty .dmrc file, but I'm only speculating.


The answer on this (similar) question solved my problem: Ubuntu gets stuck in a login loop. (the sudo chmod a+wt /tmp code)

However I now have a problem with my color scheme (the colors seem unaligned), but I'll post this in another question since it isn't very related to this problem.

Thanks for all the help!


Press CTRL+ALT+F1 and log in there and run:

sudo chown -R $USER:$USER $HOME

$USER is your username

Ex - sudo chown -R singh:singh /home/

Then press CTRL+ALT+F7 and try to log in

  • sudo chown -R singh:singh /home/<username> would be more appropriate and still it would be wrong since you could have subdirectories that need other group ownership. An example would be public_html.
    – Stanislav
    Sep 9 '15 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.