Systemd replaces init in the majority of contemporary Linux distributions. For Linux distributions like RHEL/CentOS, RockyLinux, Alma Linux, Arch, Debian, Ubuntu, and others, it is a collection of fundamental building components. Most distributions start in a GUI by default, but you can switch to text (multi-user) or vice versa.
Older Linux distributions shipped with SysV init or Upstart. A set of runlevels for the text, multi-user, and GUI systems were given by such an implementation. Runlevels are not used by systemd; instead, targets are used. When working with systemd targets, the steps to implement runlevel-like configuration are described on this page. In other words, you will learn how to use systemd rather than init levels on contemporary Linux distributions to switch between text and GUI mode.
{getToc} $title={Table of Contents}Switching from Graphical to Text (multi-user)mode
To switch to a text mode runlevel in systemd, perform these steps:
- Launch the terminal programme.
- Use the ssh command to connect to remote Linux servers.
- Identify the target unit that is default used by command
systemctl get-default
:
[root@TechArticles ~]# systemctl get-default graphical.target
To switch to text mode for the boot target use this command systemctl set-default multi-user.target
:
[root@TechArticles ~]# systemctl set-default multi-user.target Removed /etc/systemd/system/default.target. Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.
You can verifiy the changed by running systemctl get-default
[root@TechArticles ~]# systemctl get-default multi-user.target
Use the reboot command to restart the computer:
# reboot
How to Switch to a GUI as the Boot Target (Graphical User Interface)
Would you want to boot in GUI mode rather than console or text mode? Try:
- Launch the Linux terminal programme.
- Again, use the ssh command to connect to remote Linux servers.
- Identify the target unit that is default used by command
systemctl get-default
:
[root@TechArticles ~]# systemctl get-default multi-user.target
To switch to GUI mode on the boot target user this command: systemctl set-default graphical.target
[root@TechArticles ~]# systemctl set-default graphical.target Removed /etc/systemd/system/default.target. Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target. [root@TechArticles ~]#
You can verifiy the changed by running systemctl get-default
[root@TechArticles ~]# systemctl get-default graphical.target
Make careful you use the reboot command to restart the Linux computer:
# restart
Let's Understand systemd boot targets
/etc/systemd/system/default.target
controls the default target. To check it via the symbolic link, run the following command:
[root@TechArticles ~]# ls -l /etc/systemd/system/default.target lrwxrwxrwx. 1 root root 41 Mar 20 08:25 /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target
Anywaye we can get default target by the systemctl command itself too:
# systemctl get-default
Let's find every targets in systemd
run below command to get all the available targets of the system:
I am using RockyLinux 8.6, these are all the target units that are at the moment loaded and active:
# systemctl list-units --type target[root@TechArticles ~]# systemctl list-units --type target UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System cryptsetup.target loaded active active Local Encrypted Volumes getty.target loaded active active Login Prompts graphical.target loaded active active Graphical Interface local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems multi-user.target loaded active active Multi-User System network-online.target loaded active active Network is Online network-pre.target loaded active active Network (Pre) network.target loaded active active Network nfs-client.target loaded active active NFS client services nss-user-lookup.target loaded active active User and Group Name Lookups paths.target loaded active active Paths remote-fs-pre.target loaded active active Remote File Systems (Pre) remote-fs.target loaded active active Remote File Systems rpc_pipefs.target loaded active active rpc_pipefs.target rpcbind.target loaded active active RPC Port Mapper slices.target loaded active active Slices sockets.target loaded active active Sockets sound.target loaded active active Sound Card sshd-keygen.target loaded active active sshd-keygen.target swap.target loaded active active Swap sysinit.target loaded active active System Initialization timers.target loaded active active Timers 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.
To view the all active and non active target, run below command
[root@TechArticles ~]# systemctl list-units --type target --all UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System cryptsetup.target loaded active active Local Encrypted Volumes emergency.target loaded inactive dead Emergency Mode getty-pre.target loaded inactive dead Login Prompts (Pre) getty.target loaded active active Login Prompts graphical.target loaded active active Graphical Interface initrd-fs.target loaded inactive dead Initrd File Systems initrd-root-device.target loaded inactive dead Initrd Root Device initrd-root-fs.target loaded inactive dead Initrd Root File System initrd-switch-root.target loaded inactive dead Switch Root initrd.target loaded inactive dead Initrd Default Target local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems multi-user.target loaded active active Multi-User System network-online.target loaded active active Network is Online network-pre.target loaded active active Network (Pre) network.target loaded active active Network nfs-client.target loaded active active NFS client services nss-lookup.target loaded inactive dead Host and Network Name Lookups nss-user-lookup.target loaded active active User and Group Name Lookups paths.target loaded active active Paths remote-fs-pre.target loaded active active Remote File Systems (Pre) remote-fs.target loaded active active Remote File Systems rescue.target loaded inactive dead Rescue Mode rpc_pipefs.target loaded active active rpc_pipefs.target rpcbind.target loaded active active RPC Port Mapper shutdown.target loaded inactive dead Shutdown slices.target loaded active active Slices sockets.target loaded active active Sockets sound.target loaded active active Sound Card sshd-keygen.target loaded active active sshd-keygen.target swap.target loaded active active Swap sysinit.target loaded active active System Initialization ● syslog.target not-found inactive dead syslog.target time-sync.target loaded inactive dead System Time Synchronized timers.target loaded active active Timers umount.target loaded inactive dead Unmount All Filesystems virt-guest-shutdown.target loaded inactive dead Libvirt guests shutdown
systemd targets versus Sysv runlevels
Let's examine previous SysV runlevels and how systemd treats them.
Systemd target | Runlevel | Description | Old command | New command |
---|---|---|---|---|
runlevel0.target, poweroff.target | 0 | Its use to shutdown the Linux computer. | init 0 | systemctl isolate poweroff.target |
runlevel1.target, rescue.target | 1 | Use to launch the rescue, emergency mode or single user mode. | init 1 | systemctl isolate rescue.target |
runlevel2.target, multi-user.target | 2 | text-based multi-user system with out networking | init 2 | systemctl isolate runlevel2.target |
runlevel3.target, multi-user.target | 3 | Gives a Linux server a typical start in multi-user text mode with networking enabled. | init 3 | systemctl isolate runlevel3.target |
runlevel4.target, multi-user.target | 4 | Use text mode for certain reasons. | init 4 | systemctl isolate runlevel4.target |
runlevel5.target, graphical.target | 5 | IIt is same as runlevel 3 and boot into the GUI mode with networking. | init 5 | systemctl isolate graphical.target |
runlevel6.target, reboot.target | 6 | Restart your Linux machine | init 5 | systemctl isolate reboot.target |
Was this article of use to you? Post your insightful thoughts or recommendations in the comments section if you don't find this article to be helpful or if you see any outdated information, a problem, or a typo to help this article better.