In this part of RHCSA exam preparation you will learn how to manually change into a different boot targets. This article will also teach you how to set a default boot targets to automatically boot into graphical or multi-user target on Red Hat Enterprise Linux system.
In this tutorial you will learn:
- How to check default boot target
- How to manually switch between different targets
- How to set default boot to multi-user target
- How to set default boot to graphical target
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||Red Hat Enterprise Linux 8|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
What are runlevel targets
You can think of boot target as specific level of operation. So for example if you prefer to use Graphical user interface ( given that GUI is installed ) you may want to change the level of operation to
graphical.target. Similarly, for non-graphical multi-user operational level you will need to change to
If you are familiar with SysV which was the default initialization standard for many GNU/Linux systems prior to the
systemd proliferation you might recall the graphical target as
runlevel 5 or multi-user target as
runlevel 4. In fact not much has changed and the runlevel nomenclature still exist. Using the following command you can list all runlevel targets available on your RHEL system:
# ls -l /lib/systemd/system/runlevel*.target
For all possible targets use:
# systemctl list-units --type target or # systemctl list-units --type target --all
|Runlevel||Target Unit||Target Unit Description|
|0||runlevel0.target or poweroff.target||Changing your system to runlevel 0 will shutdown the system and power off your server/desktop.|
|1||runlevel1.target or rescue.target||Also known as single mode the rescue runlevel is use for system troubleshooting and various system administration tasks.|
|2||runlevel2.target or multi-user.target||User defined runlevel. By default, identical to runlevel 3.|
|3||runlevel3.target or multi-user.target||This is a multi-user and non-graphical runlevel. Multiple users can log in via local consoles/terminals or remote network access.|
|4||runlevel4.target or multi-user.target||User defined runlevel. By default, identical to runlevel 3.|
|5||runlevel5.target or graphical.target||Multi-user graphical runlevel. Multiple users can log in via local consoles/terminals or remote network access.|
|6||runlevel6.target or reboot.target||Changing your system to this runlevel will reboot your system.|
On your RHCSA exam when you get stuck or simply cannot remember some of the above terminology regarding the runlevels consult the manual page by executing
How to check and change default boot target
First, we will learn how to check a currently configured default runlevel boot target. Once done, we will set a default runlevel target of our system to runlevel 3 that is to the
multi-user.target target unit. Setting a default runlevel target will instruct your system to automatically boot into a pre-configured runlevel.
- Check a default runlevel system configuration:
# systemctl get-default graphical.target OR # ls -l /etc/systemd/system/default.target
The above command will output a name of currently set default runlevel target unit.
- Set default runlevel target unit to
multi-user.targettarget unit. This will configure your system to boot into
runlevel3the next time you reboot your system.
# 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.
DID YOU KNOW?
You can refer to single target units via different names. For example, for your RHCSA exam you may find it easier to remember
multi-user.target. Not only it is easier to remember but also it is faster to type, hence saving you some time on your exam. For example the following four commands are completely identical. The best command to use is the one you remember the easiest:
# systemctl set-default multi-user.target # systemctl set-default multi-user # systemctl set-default runlevel3.target # systemctl set-default runlevel3
To better understand what is going on here you should first review the Create hard and soft links RHCSA objective. Once ready note that targets such as for example the
multi-user.targetis simply a symbolic link of the
- Reboot your system:
How to change manually into a different runlevel target
The above section, explained how to change a default runlevel. This means that the next time the system is rebooted it will boot into a user selected runlevel. Next, we will learn how to change runlevel on-fly without a need for reboot. This can be accomplished by the use of the
systemctl command with a combination of
In the below example we will temporarily change from the
graphical runlevel to
- Change to
# systemctl isolate multi-user
The above a command simply disabled the
graphicalrunlevel and corresponding services.
- If you cannot see login prompt you might need to change to a different TTY console by using the combination of
- Reboot your system by manually switching to
systemctlcommand. Can you also use runlevel target shutdown and power off your system?
- Set your system to boot directly to
multi-usertarget. Reboot your system and confirm that the system persistently boots into
- Try to switch repeatedly between the
graphicalrunlevel. Why you cannot see the login prompt directly when switching from the
- This is an extra curriculum question for good students and those who are not afraid of little hassle and self research.
While working on the question 4 you might end up with a broken system. Hence proceed only on non-production system such as sandbox virtual machines etc.
Again, do not attempt this question if you are not ready to possibly break your system! Set your default boot target to
reboot.targetunit and reboot your system. Can you fix the constant reboots and set your default runlevel back to say