Remove Desktop GUI from Raspbian

If you’re looking to save some space on your Raspberry Pi (mine runs on a 4 GB SD card), run these commands to remove all desktop/gui-related programs:

sudo su

apt-get install deborphan -y

apt-get autoremove --purge \
libx11-.* lxde-.* raspberrypi-artwork \
xkb-data omxplayer penguinspuzzle \
sgml-base xml-core alsa-.* cifs-.* \
samba-.* fonts-.* desktop-* gnome-.* -y

apt-get autoremove --purge $(deborphan)

apt-get autoremove --purge

apt-get autoclean

That will remove the desktop programs and any orphan programs left behind.

Check out more posts about the Raspberry Pi here: Raspberry Pi Posts