How to Change default runlevel in CentOS 7 / RHEL 7

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” :

See also  How to Install wget on Fedora 16

Method 1 :

[root@centos72 ~]# systemctl get-default
multi-user.target

Method 2 :

[root@centos72 ~]# 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 :

[root@centos72-gui ~]# systemctl get-default
graphical.target

Method 2 :

[root@centos72-gui ~]# 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:

[root@centos72 ~]# runlevel
N 3
[root@centos72-gui ~]# 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 :

See also  How to Setup Webmin 1.670 on CentOS 6.5

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

Comments

1 Comment

  • Avatar 5irCh4rms says:

    I believe #s 4 and 5 are reversed:

    The following should set the default runlevel as NON-GUI mode:
    systemctl set-default multi-user.target

    And this should set the default runlevel at GUI mode, starting GNOME etc.:
    systemctl set-default graphical.target

    According to RedHat documentation in the link you provided anyways.

Leave a Reply to 5irCh4rms Cancel reply

Your email address will not be published. Required fields are marked *