Controlling Targets - runlevels with systemd

On systemd, "runlevels" are now referred to as "targets". The command to display your current target level is: systemctl get-default

Controlling Runlevels

To display the current runlevel of your system, you will need to issue the following command: systemctl get-default


$ systemctl get-default
graphical.target

The reply back from the system is "graphical.target". Basically the runlevel "graphical.target" is the equivalent to the traditional runlevel 5, Full user access with Graphical Display and networking.

You can display the new runlevels/targets by issuing the following command:

ls -al /lib/systemd/system/runlevel*


$ ls -al /lib/systemd/system/runlevel*
lrwxrwxrwx 1 root root   15 Mar 17 21:36 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx 1 root root   13 Mar 17 21:36 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx 1 root root   17 Mar 17 21:36 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx 1 root root   17 Mar 17 21:36 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx 1 root root   17 Mar 17 21:36 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx 1 root root   16 Mar 17 21:36 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx 1 root root   13 Mar 17 21:36 /lib/systemd/system/runlevel6.target -> reboot.target

From the above we can see that we still have seven different runlevels ranging from system poweroff to system reboot.

0 poweroff.target
1 rescue.target
2 multi-user.target
3 multi-user.target
4 multi-user.target
5 graphical.target
6 reboot.target

Setting a new Default Target/Runlevel

In the following example we are going to change the runlevel from "graphical.target" to "multi-user.target".

To do this we issue the following commands:


rm /etc/systemd/system/default.target
ln -s /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target

Alternatively you could issue the link command with the "-f" parameter indicating that the destination file is to be removed:


ln -sf /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target

Here we are first deleting the existing "default.target" and then replacing with our link command. Our new "target.default" will be that of "runlevel3.target".


# rm /etc/systemd/system/default.target
rm: remove symbolic link ‘/etc/systemd/system/default.target’? y

# ln -s  /lib/systemd/system/runlevel3.target  /etc/systemd/system/default.target

# systemctl get-default 
runlevel3.target

Now if we were to reboot the system, it would start in "runlevel 3 - multi-user.target".

To revert back to the original runlevel "runlevel 5 - graphical.target" we would simply issue the following commands:


# systemctl get-default 
runlevel3.target

# rm /etc/systemd/system/default.target
rm: remove symbolic link ‘/etc/systemd/system/default.target’? y

# ln -s  /lib/systemd/system/runlevel5.target  /etc/systemd/system/default.target

# systemctl get-default 
runlevel5.target

For the system to switch to the new runlevel, you would need to reboot your system or issue the "init" command followed by the relevant runlevel.