How to change targets with systemd on Linux

Estimated read time 4 min read

When you start the Linux operating system, the system that controls the startup processes that occur respectively is called “init system”. Some Linux distributions use SysV launcher, and some distributions use systemd. If you’re using a desktop computer, you’ll want to access the graphical interface once the startup process is complete. If you don’t need a desktop on the server computer, you want to access the command line, not the graphical interface. In this article, we will see how we can switch between graphics and console and set the default boot target in a Linux distribution that uses the systemd management system.

First, let’s see the target states that are installed and active in our system. You can use the “systemctl list-units --type=target” command for this.

linux@rpi4:~ $ systemctl list-units --type=target
  UNIT                   LOAD   ACTIVE SUB    DESCRIPTION                            loaded active active Basic System      loaded active active Local Encrypted Volumes           loaded active active Login Prompts       loaded active active Graphical Interface  loaded active active Local Integrity Protected Volumes    loaded active active Preparation for Local File Systems        loaded active active Local File Systems        loaded active active Containers      loaded active active Multi-User System  loaded active active Network is Online         loaded active active Network      loaded active active NFS client services loaded active active User and Group Name Lookups           loaded active active Path Units   loaded active active Preparation for Remote File Systems       loaded active active Remote File Systems      loaded active active          loaded active active Slice Units         loaded active active Socket Units            loaded active active Swaps         loaded active active System Initialization        loaded active active System Time Set          loaded active active Timer Units     loaded active active Local Verity Protected Volumes

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
24 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

Many of the situations listed above are actually a requirement of the ultimate goal (graphical interface, console interface, etc.). Since the cases we are currently interested in are “” and “”, we do not take the others into consideration.

First, let’s see the boot target set by default in our system. For this we use the “systemctl get-default” command.

$ systemctl get-default

You can see that the default opening target set in our system is the graphical interface “”. The conclusion we can draw from here is that when our system starts, all services will be run respectively and you will access the desktop manager with the graphical interface.

Well, if you don’t need the desktop or no longer need it, you may want to stop it and reduce system resource usage. In this case, how do we stop the graphical interface and go to the screen we call console, also called the command line, which we will express as “” in our commands.

from to multiuser-target

Our system is currently running in the graphical interface we call What is done here is not to open a Terminal window on the desktop screen. It is to stop the desktop manager completely. You should pay attention. Thanks to the command below, programs using the desktop manager and graphical interface are now completely stopped. You are at the command line.

sudo systemctl isolate

from multiuser-target to

If you want to restart the graphical interface, you can use the command below. As a result of this command, the graphical interface and desktop manager will be restarted.

sudo systemctl isolate

First boot default target setup

The transition commands we gave above are used for initialization, termination and transition operations after the system is turned on. Now, let’s set which state we want your system to target when it first turns on. For this we will use the “systemctl set-default ” command.

sudo systemctl set-default
sudo systemctl set-default

Thanks to these commands, you can reduce resource usage by stopping the graphical interface at any time and switch between them when you need.

İbrahim Korucuoğlu

Yazar, bilişim ve teknoloji alanında derlediği faydalı içerikleri bu blogta paylaşmaktadır.