CHANGE RUNLEVEL IN RHEL 7 /CENTOS 7 WITH SYSTEMD USING SYSTEMCTL
In this article we are going to discuss on how to change runlevel in RHEL 7 / CentOS 7 with systemd using systemctl command.
Runlevel is nothing but a process which is Responsioble 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 forgotten root password, Runlevel 6 for Reboot the system and so on. In 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.
There are 7 Runlevels are available in Linux (Compared between RHEL 6 & RHEL 7):
The RHEL 7 / CentOS 7 comes with systemd (System Management Daemon) which is a init system uses target instade of Runlevel Numbers but the concept is 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 concern with below two Targets here in this article :
- 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.
- 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.
Also Read :
Follow the below Steps to Change Runlevel with Systemd with systemctl
To check currently 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 restart 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.
So This is how we can change the Runlevel in RHEL 7 / CentOS 7.
If you found this article useful then Like Us, Subscribe our News Letter Or if you have something say then feel free to comment on comment box below.