Cannot login to ubuntu after startx command
Solution 1
To solve the problem:
Open a terminal window Ctrl + Alt + T and type in the commands:
cd ~
sudo chown username:groupname .Xauthority
(replace username and groupname with that of your own, usually your group name will be same as your username.)
Avoid running startx
as root:
Since you started X system as root (by logging-in as root and using startx
) the file .Xauthority
in your user-home directory (~
) got owned by the root, and that's the reason why you're stuck with log-in loops. And that's why you shouldn't run sudo startx
. You can solve this by giving the ownership of the file back to your user as shown above.
Reference:
Solution 2
I wanted to add something to precise's answer. I did exactly that but it wasn't enough in my case. If someone still can't log in after following precise's instructions, do this:
ls -l ~/.ICEauthority
If it says something like -rw------- 1 root root 684 may 9 11:56 /home/user/.ICEauthority
, do
sudo chown user:user ~/.ICEauthority
where user
is, of course, your username.
Related videos on Youtube
Siddharth Thevaril
Updated on September 18, 2022Comments
-
Siddharth Thevaril almost 2 years
I wanted to manually configure the internet settings & decided to seek help from this website. Ubuntu did not allow me to perform step 1 saying,
X: user not authorized to run the X server, aborting
so I logged in as superuser by executing
sudo -s
. Then I executed step 1. Suddenly all the tray icons disappeared & the only thing that was being displayed was the wallpaper. I wasn't able to shutdown/restart & chose to shutdown the laptop directly with power button. Upon restart, I had the following problems,PROBLEMS :
- I am able to login with a guest account.
- I'm unable to login with my user account. Logging in brings me back to the login screen.
I am using ubuntu 13.04. How can I fix this?
-
gartenriese over 10 yearsWhen I try this, it says: "sudo: unable to change to sudoers gid: Operation not permitted"
-
precise over 10 years@gartenriese please try these commands:
find /home/username -maxdepth 1 -type f -execdir sudo chown username:username {} +
andfind /home/username -maxdepth 1 -type d -execdir sudo chown username:username {} +
from atty
or from recovery mode asroot
after mounting the/
with RW permissions withmount -o remount,rw /
-
gartenriese over 10 yearsSorry for the late answer, but it worked when I tried it in the terminal that opens when you press ctrl+alt+F1. Thanks though!
-
Ken almost 7 yearsI foolishly ran sudo startx on Ubuntu 16.04 LTS to see what would happen and I couldn't log in. I logged onto a different user and I tried changing ownship of .Xauthority, I tried removing .Xauthority and nothing worked. I removed the .Xauthority file again and tried the two find commands to change ownership of all files and directories in home, and it worked. Thanks for that solution, nice job!