I foolishly ran a GUI graphics tool as sudo! I was using a nvidia configuration tool and should have used gksudo
instead of sudo
. Here is how to undo the damage
- press ctrl + shift + F2 to open a terminal
- enter your username, then password
cd ~
to get to the home directory
ls -l -a
to see a list of all the hidden configuration files in the folder
If line containing the .Xauthority
file shows 'root' in either the third or fourth column or both then continue with this guide. If not, you are having a bad problem and you will not go to space today.
A bad line would look like this,
-rwxrwx--- 1 root root 57 Jan 6 17:57 .Xauthority
This means that root not $USER owns this file, you can remedy the situation by using chown
sudo chown $USER:$USER .Xauthority
This changes the owner of the .Xauthority
file from root to you. If you need more clarification of what this does, use chown --help
ls -l -a
and check that your username (all spelled out, not "$USER") is where 'root' used to be.
Go back to the lightdm login screen by typing ctrl + shift + F7
Try logging in, did it work?
If not go back to the previous terminal by typing ctrl + shift + F2
look at the output of ls -l -a, make sure that the first column does not look like this
-------rwx 1 root root 57 Jan 6 17:57 .Xauthority
this means that the user and the group cannot access this file. to fix this, use the chmod
command.
sudo chmod ug+rwx .Xauthority
Hope this helps. I have managed to do this on three separate occasions so I hope this saves people some grief.