brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: systemctl set-default multi-user.target boots a Linux box without the desktop

Linux
~/tips/tip-systemd-systemctl-set-default

systemctl get-default

Makes a Linux machine boot to a text login without starting the desktop.

An old laptop or mini PC with a full desktop install makes a fine little server, but then the desktop starts at every boot and eats memory for nobody. You don’t have to uninstall anything to stop that. You only change the target systemd boots into.

First see what it boots into now:

systemctl get-default

A desktop system answers graphical.target. A server wants multi-user.target, the non-graphical, multi-user state with networking and all your services:

sudo systemctl set-default multi-user.target

Under the hood this only points the default.target symlink at a different target. Nothing is removed, and since graphical.target pulls in multi-user.target anyway, every service that ran before still runs; only the display manager and the desktop session stay off. After the next reboot you get a text login, and SSH works as before. Changed your mind? sudo systemctl set-default graphical.target brings the desktop back on the next boot.

The caveat is about doing it right now instead of after a reboot. systemctl isolate multi-user.target switches immediately, but it stops every unit that isn’t part of the new target, and the systemctl manual calls it dangerous because that can include the graphical session or terminal you are typing in. If you’re logged in on that desktop, save your work first, or simply reboot. And if you need the desktop once in a while, sudo systemctl start graphical.target starts it for one session without changing the default.

Further reading: systemctl(1) manual page, systemd.special(7) manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link