In earlier version of RHEL, we used to change the runlevels
in /etc/inittab file.
But inittab is no longer used when using systemd. systemd uses
‘targets’ instead of runlevels.
By default there are 2 main targets
graphical.target à
Runlevel 5 having GUI
multi-user.targetàRunlevel
3 text based
To view current default runlevel/target
# systemctl get-default
To set a different target
#systemctl set-default TARGET.target
Ex: systemctl set-default graphical.target
Verification:
# systemctl get-default
graphical.target
Now reboot the machine to check whether the machine is booting
up into graphical mode.
Alternate method to
change the runlevel
You may be noticed the similar output when the systemctl
set-default multi-user.target command is issued. What the command done is
nothing but making a symbolic link of runlevel targets to the default target
file.
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/multi-user.target'
'/etc/systemd/system/default.target'
Check the current level.
# systemctl get-default
multi-user.target
Before making the symbolic link, let’s list out the files in
the systemd directory.
# ls /lib/systemd/system/runlevel*target -l
lrwxrwxrwx. 1 root root 15 Aug 3 13:44 /lib/systemd/system/runlevel0.target
-> poweroff.target
lrwxrwxrwx. 1 root root 13 Aug 3 13:44 /lib/systemd/system/runlevel1.target
-> rescue.target
lrwxrwxrwx. 1 root root 17 Aug 3 13:44 /lib/systemd/system/runlevel2.target
-> multi-user.target
lrwxrwxrwx. 1 root root 17 Aug 3 13:44 /lib/systemd/system/runlevel3.target
-> multi-user.target
lrwxrwxrwx. 1 root root 17 Aug 3 13:44 /lib/systemd/system/runlevel4.target
-> multi-user.target
lrwxrwxrwx. 1 root root 16 Aug 3 13:44 /lib/systemd/system/runlevel5.target
-> graphical.target
lrwxrwxrwx. 1 root root 13 Aug 3 13:44 /lib/systemd/system/runlevel6.target
-> reboot.target
As per the previous step, current default run level 3.
Issue
the following command to make a symbolic link of runlevel5.target to
default.target file.
# ln -sf /lib/systemd/system/runlevel5.target
/etc/systemd/system/default.target
or
# ln -sf /lib/systemd/system/graphical.target
/etc/systemd/system/default.target
Again check the current level.
# systemctl get-default
runlevel5.target
Now the default runlevel is 5 (graphical mode), reboot the
server and check it out.
# reboot
No comments:
Post a Comment