How to boot Debian headless (without GUI)

0

I configured a web mapping service on a debian system in VirtualBox and used to GUI to make it easier for me as a linux newbie. But now the system is done and working and shall be moved to a VM on our cloud service for customer use. There the GUI is obviously not needed and will only consume unnecessary resources.

I tried to find out, which config file to edit or which command to issue to make Debian start headless. But my search results are surprisingly bare - I either find instructions for headless installtion or for way more specific cases than mine.

What I found was this:

systemctl disable lightdm

But it came with warnings, that I might not be able to re-enable it, if needed.

So I came here to ask more experienced users if
a) this is the right command for what I want and
b) if there is a way to revert this, should I ever need it

Any help for a linux starter would be very appreciated!

Merion

Posted 2019-06-20T11:06:44.860

Reputation: 3

Answers

1

Since systemd, the OS always boots into a so-called "target". On GUI systems, the default boot target is graphical.target, whereas on systems without any DE or graphical environment, it is called multi-user.target.

The proper way to make the machine boot only into tty, without any GUI, is to switch the default target:

systemctl set-default multi-user.target

To check what is the current default target:

systemctl get-default

And I do not know about the term headless, I've never seen it being used for such a case, and that's probably the reason why you couldn't find any information.

And to actually answer your questions:

Is this the right command for what I want

No, it is not. This command only disables the specific desktop manager. It doesn't actually disable the GUI, and the system will still boot and startup most GUI services and processes - therefore it will still use more resources. I've shown you the proper way on a systemd-based distro.

If there is a way to revert this, should I ever need it

Just enable it. A warning is a warning, it is there because many problems can occur at random - we cannot predict them. If by chance a problem really occurs when the time to enable it back on comes - just post another question.

And if you use systemd to make the system boot into multi-user.target, you can just revert it by switching back to graphical.target:

systemctl set-default graphical.target

Fanatique

Posted 2019-06-20T11:06:44.860

Reputation: 3 475

Wow, thank you! Exactly what I was looking for and I even learned more about systemd, very cool!

I think I will also look up the term headless, see why I thought this to be the correct term. – Merion – 2019-06-20T13:16:01.530

1Update Appearently the term headless is used for hardware, so basically the server system itself, not the software on it: https://en.wikipedia.org/wiki/Headless_computer – Merion – 2019-06-20T13:29:48.150