I was logged into my raspberry pi and downloading some python packages. At one point the raspberry pi froze and I could not do anything to safely shutdown etc, so I pulled the power cord.
Now I cannot log into the raspberry pi through the GUI. I can login using the command line but the command startx does not work.

p.s: I've tried most of the solutions already presented (sudo chown -R pi.pi *)

  • So, do you mean that when you turn on the raspberry pi, it stock on shell mode and doesn't go to GUI mode(startx) like this image? Commented Jan 14, 2020 at 15:40
  • Does the startx command fail with a specific error message ? Log ?
    – Kate
    Commented Jan 14, 2020 at 19:44
  • Are you saying that when you try to login to the GUI, it doesn't login?
    – LilData777
    Commented Jan 30, 2023 at 13:39
  • Abandoned post by Unregistered user.
    – Milliways
    Commented May 30, 2023 at 7:52

3 Answers 3


Try entering sudo raspi-config on boot then select the first option which should say B1 Desktop / CLI then you can pick B4 Desktop autologin this option lets you boot directly into the GUI on boot time. Once you enable it reboot the pi and you'll see if it works. This has actually happened to me when I first got my pi, all I did was re-install raspbian but that is alot of un-needed work, hopefully this option helps.

enter image description here


For the future, when frozing, I recommend using a key combination Ctrl+Alt+F1/F2/F3 to switch to another tty. You can continue to work there or check the system.

First check that the SD card is correct and not full.

Second if you have setting for startx, they are in /etc/X11/xinit/xinitrc or ~/.xinitrc

In this case, check what is there and correctly configured: Setting up a window manager or desktop (for example, GNOME, KDE, XFCE). Setting the DISPLAY environment variable. Assign launch options for the X server. Run applications and scripts on X server startup.

In my case it would be . /etc/X11/Xsession

If you have the opportunity and you are booting from a SD card, use another working SD card to check these settings.


reboot in SSH ? .

sudo reboot
  • 1
    We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed or you risk to get down votes.
    – Ingo
    Commented Jan 15, 2020 at 8:54

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.