1

Long story short: I have a Raspberry Pi 4 running the default Raspbian installation - the one intended for use with a monitor + keyboard + mouse. But I've set everything up and right now I'm actually running it headlessly, I can SSH into it to do everything. There's no monitor connected - only a LAN cable, external drive via USB, and the power adapter. Everything is working as I want.

But I'm worried that the desktop services might still be running unnecessarily, and I'd prefer to stop/uninstall them. How do I check? What should I uninstall?

1

There's a handy option on sudo raspi-config for "boot to command line", "boot to command line (auto login)", "boot to desktop" or "boot to desktop (autologin)".

If you choose either of the "command line" options then all that stuff that @Goldilocks is suggesting gets done for you. It will disable lightdm and the X windows server. None of that stuff you don't need will get started.

I don't usually bother doing that on my headless systems as it only wastes RAM, it doesn't cost too much in CPU to run an idle desktop. Running that way also means I can use RealVNC to access a virtual desktop on a headless system.

| improve this answer | |
0

But I'm worried that the desktop services might still be running unnecessarily

Unless you have autologin enabled, it would just be the display manager, which implements the GUI login page. This probably does not occupy more than 50-100 MB of memory, which, since it won't see any action, is liable to be swapped out when needed (and I'd guess a large chunk of it will be shared by things that are in real use).

However, it is pretty easy to disable without uninstalling anything,1 and much of it is likely to be a dependency of stuff you do want anyway):

sudo systemctl set-default multi-user.target

First check systemctl get-default to make sure it is currently graphical.target, which is what it should be if a GUI is running. However, at least at some point in the past desktop Raspbian was (wrongly) configured to always use multi-user.target, and just added the display manager to that.

Hopefully that has changed.2 If not, try:

sudo systemctl mask lightdm

This is a ham-fisted version of disable (see man systemctl); lightdm is the aforementioned display manager. In any case, probably just switching to multi-user.target, which is intended for non-graphical console login, should be enough.


  1. I do not think they make micro SD cards small enough to worry about removing it, by which I mean the base X server + the display manager + LXDE (the desktop environment). However, there still could be a ton of GUI application stuff. But unless you are tight for space don't worry about it; in any case I don't think you will really be able to trim more that 0.5 or so GB.

  2. I always use Raspbian lite but sometimes install a desktop afterward (that's never default enabled), so I don't have a "full version" image here to check.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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