How to change default run-level in RHEL or CentOS 7

How to change default run-level in RHEL or CentOS 7


There is change in process to setup default run-levels from init 3 (multi-user) to init 5 (Graphical) and vice versa. If we see "/etc/inittab" file it's been changed from RHEL/CentOS 6.x to 7.x.

[root@localhost ~]# cat /etc/inittab
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#


To check what is the default run-level configured currently :

[root@localhost ~]# ls -l /lib/systemd/system/default.target
lrwxrwxrwx. 1 root root 16 Mar 29 19:57 /lib/systemd/system/default.target -> graphical.target


This indicates graphical.target means init 5 is default runlevel configured currently:

To change it to multi-user.target (init 3) :

[root@localhost ~]# systemctl set-default multi-user.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.


To switch from graphical to multi-user:
[root@localhost ~]# systemctl isolate multi-user.target
 

[root@localhost ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.


To switch from multi-user to graphical:
[root@localhost ~]# systemctl isolate graphical.target

Comments

Popular posts from this blog

Recover or restore initramfs file in RHEL or CentOS 7

Space reclamation / UNMAP on RHEL or CentOS 7

How to recover /boot partition on RHEL or CentOS 7?