I have my Raspberry Pi 3 since a few days now. OS is Raspbian (the newest one). I read if the Pi Starts in Command Line Mode, you can type startx in order to start the GUI. The Pi started in the GUI from beginning, so I asked myself what happens if I (logged in as User 'pi') would happen if I type following Command:

sudo startx

What happened? On first sight my configurations seem to have resetted, but now I was logged in as User 'root'. I don't wanted that, so I rebooted. Now, I am Stuck in the Login Screen. If I try to login as pi with the right password entered, the screen goes Black, and I get thrown back into Login Screen. I just don't know what I should do. I really don't want to Format the SD to re-install Raspbian.

Thank you very much for the help.

3 Answers 3


First of all, you are expected to post some of your system logs. We ignore it for now, because it seems that it is your first time with the stackexchange.

According to your story, I guess some kind of overwrite may be performed by root user on the files (mostly lxde confs) which are supposed to be owned by pi.

Give the following command (run as root) a chance:

 root@raspberry:~# chown pi:pi -R /home/pi

root@raspberry:~# chown -R pi:pi /home/pi
  • Shouldn't it be chown -R pi:pi /home/pi I think options go before owner:group.
    – Ghanima
    Commented Oct 17, 2016 at 23:18
  • @Ghanima, yes you are right. But tested now, both of them works =)
    – vaha
    Commented Oct 17, 2016 at 23:21
  • Maybe you compiled your command line tools with the lazy flag ;)
    – Ghanima
    Commented Oct 17, 2016 at 23:23
  • Thanks for your answer. Sorry for the bad formatting of my answer, it's the first time :). Today I found out that I can still login to user 'pi' via SSH, so at least I can enter the command you gave me. It worked out perfectly, thank you very much :D. Commented Oct 18, 2016 at 10:32

The solution for me, after trying the above and login still not working, was deleting .xsession-errors under /home/pi - sugested at https://www.raspberrypi.org/forums/viewtopic.php?p=74457.

Best regards, T

sudo startx

would open the X GUI as the root user, but this shouldn't affect how you login as the pi user. Root and pi user are separate, and you shouldn't ever need to use the root GUI Are you sure the cause isn't something else? You may have to re-install Raspbian. I had something similar to this happen where it took a while to load the login screen, and crashed most of the time. I had to re-install Raspbian. Mine was probably caused because of some corrupted data, and that is probably what yours is too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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