How to Change default runlevel in CentOS 7 / RHEL 7

Share this Article :

Change default runlevelIn CentOS 7 and RHEL 7, the systemd process replaces the init process for starting services at boot time and also for changing the runlevels. It uses “targets” instead of run-levels and relies on systemctl command to change runlevel or to change the target.

The systemd provides much more control than the init process does while still supporting existing init scripts.

Take note that in RHEL 7 and CentOS 7, any edits of /etc/inittab file will not take effect.

The following articles describe how to change default runlevel in CentOS 7 / RHEL 7.

1. How to determine the state that the system currently configured to boot to :

# systemctl get-default

Example 1 :
If the system running on Non-GUI Mode, “systemctl get-default” command will return “multi-user.target” :

Method 1 :

[[email protected] ~]# systemctl get-default
multi-user.target

Method 2 :

[[email protected] ~]# ls -al /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 37 May 30  2015 default.target -> /lib/systemd/system/multi-user.target

Example 2 :
If the system running on GUI Mode, “systemctl get-default” command will return “graphical.target” :
Method 1 :

[[email protected] ~]# systemctl get-default
graphical.target

Method 2 :

[[email protected] ~]# ls -al /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 36 Jun  5  2015 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target

However, you can still use the runlevel command as it was left intact for backward compatibility:

[[email protected] ~]# runlevel
N 3
[[email protected] ~]# runlevel
N 5

In case you are required to change from your CentOS 7 from Non-GUI (text-based) mode to GNOME Desktop mode, you have to ensure the following group of packages has been installed properly :

a) Server with GUI (This is for server)
b) GNOME Desktop
c) Graphical Administration Tools

2. How to Install Gnome GUI in CentOS 7 :

# yum groupinstall "GNOME Desktop" "Graphical Administration Tools" "Server with GUI"

3. How to list all currently loaded and available targets :

# systemctl list-units -t target
UNIT                 LOAD   ACTIVE SUB    DESCRIPTION
basic.target         loaded active active Basic System
cryptsetup.target    loaded active active 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.target       loaded active active Network
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
slices.target        loaded active active Slices
sockets.target       loaded active active Sockets
swap.target          loaded active active Swap
sysinit.target       loaded active active System Initialization
timers.target        loaded active active Timers

In below example, the following target are required to be laoded :

graphical.target     loaded active active Graphical Interface
multi-user.target    loaded active active Multi-User System

How to Change default runlevel

4. How to Change default runlevel from Non-GUI (text-based) mode to GNOME Desktop in CentOS 7 / RHEL 7

# systemctl set-default multi-user.target

5. How to Change default runlevel from GNOME Desktop to Non-GUI (text-based) mode in CentOS 7 / RHEL 7

# systemctl set-default graphical.target

Resource :
https://access.redhat.com/articles/754933

Leave a Reply