Change Runlevel In Rhel 7/Centos 7 With Systemd Using Systemctl

In this article, we are going to discuss how to change runlevel in RHEL 7/CentOS 7 with systemd using systemctl command. Runlevel is nothing but a process which is Responsible for how the Linux system will Start or Halt/Shutdown. should it start with GUI Mode or should it start with Text Mode is decided by Runlevel and also which service should start at startup and which is not also decided by Runlevel. It is identified by Numbers From 0,1,2…6. For Example, normally Linux start in Runlevel 3 or Runlevel 5, System halt/shutdown at Runlevel 0, Runlevel 1 is for Troubleshooting Part like reset forgot the root password, Runlevel 6 for Reboot the system and so on. In a previous version of Linux Operating Systems (RHEL 6, RHEL 5 or before) we have to configure /etc/inittab to make changes in Runlevel but in RHEL 7 Runlevels can be configured by command systemctl.

Change Runlevel In Rhel 7/Centos 7 With Systemd Using Systemctl

Change Runlevel In Rhel 7/Centos 7 With Systemd Using Systemctl

There are 7 Runlevels are available in Linux (Compared between RHEL 6 & RHEL 7):

Change Runlevel In Rhel 7/Centos 7 With Systemd Using Systemctl

Runlevel

The RHEL 7 / CentOS 7 comes with systemd (System Management Daemon) which is a init system uses target instead of Runlevel Numbers but the concept is the same.

To List, all active units/services just run the below command.

[root@oracledb ~]# systemctl list-units   ---> To list all Units/Services

Or you can filter the unit list to find targets by using the below command.

[root@oracledb ~]# systemctl list-units --type=target   ---> Filter the Units to find the Targets
UNIT                  LOAD   ACTIVE SUB    DESCRIPTION
basic.target          loaded active active Basic System
bluetooth.target      loaded active active Bluetooth
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-online.target loaded active active Network is Online
network.target        loaded active active Network
nfs-client.target     loaded active active NFS client services
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
sound.target          loaded active active Sound Card
swap.target           loaded active active Swap
sysinit.target        loaded active active System Initialization
timers.target         loaded active active Timers

As shown on the list above we are a concern with below two Targets here in this article :

  1. multi-user.target – In this type of target system starts in Text Mode (Command Prompt Mode) with Multi-User Access, Networking, and all active Services. Also referred and Runlevel 3.
  2. graphical.target – In this type of target system starts with Graphical User Interface (GUI) with Multi-User Access, Networking, and all active Services. Also referred and Runlevel 5.

Follow the below Steps to Change Runlevel with Systemd with systemctl

To check currently the system is running in which Runlevel by using below command.

[root@oracledb ~]# systemctl get-default   ---> To check the current Runlevel
graphical.target   ----> Graphical User Interface (GUI)

Here currently I am in Graphical User Interface (GUI) or Runlevel No. 5. Also, you can use the below command to check the current Runlevel.

[root@oracledb ~]# runlevel
N 5   -----> Runlevel 5

To Switch the Runlevel to Text mode use the below command.

[root@oracledb ~]# systemctl set-default multi-user.target   ---> To change Target to Text Mode
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

After running the above command just reboot the system to take effect.

[root@oracledb ~]# reboot

After reboot, the system will start in Text mode, you can confirm the current Runlevel by below command.

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

# Or you can use below command to check the same.

[root@oracledb ~]# runlevel
N 3

Note: Here N 3 means Runlevel 3, which is multi-user.target in RHEL 7

If you want to switch to GUI from Text Mode you can use the below command.

[root@oracledb ~]# systemctl set-default graphical.target   ---> To change the Target to GUI Mode
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

Then restart the system.

[root@oracledb ~]# reboot

After restarting the system it should start in GUI mode, To confirm the current Runlevel use the below command.

[root@oracledb ~]# systemctl get-default
graphical.target
[root@oracledb ~]# runlevel
N 5

Note: Here N 5 means Runlevel 5, which is graphical.target in RHEL 7.

That’s all, In this article, we have explained Change Runlevel In Rhel 7/Centos 7 With Systemd Using Systemctl. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment.

Share this:

Mangesh Dhulap

This is Mangesh Dhulap the Founder and Editor of IT SMART TRICKS have 6+ years of Industrial Experience. We expect from our visitors to like, share, and comment on our posts.

You may also like...

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.