Linux Administrator

How to Change Default Runlevel in CentOS 7 and RHEL 7

There are differences in the runlevels according to the operating system. Seven runlevels are supported in the standard Linux kernel (i.e., core of the operating system). They are:

Runlevel in Linux

0 – System halt; no activity, the system can be safely powered down.
1 – Single user; rarely used.
2 – Multiple users, no NFS (network filesystem); also used rarely.
3 – Multiple users, command line (i.e., all-text mode) interface; the standard runlevel for most Linux-based server hardware.
4 – User-definable
5 – Multiple users, GUI (graphical user interface); the standard runlevel for most Linux-based desktop systems.
6 – Reboot; used when restarting the system.

By default Linux boots either to runlevel 3 or to runlevel 5. The former permits the system to run all services except for a GUI. The latter allows all services including a GUI.

In this article I will explain how you can change the default runlevel in CentOS/RHEL/Fedora system.

Change Default Runlevel

Follow the below methods to change the default runlevel.

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

Method 1 :

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

# systemctl get-default
multi-user.target

Method 2:

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

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

# runlevel
N 3

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

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

2. How to install GNOME GUI on CentOS 7. Run the below command to install GNOME GUI:

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

3. Run the below command to list of all currently loaded and available target.

# 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 loaded :

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

Change the Default Runlevel

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

# systemctl set-default multi-user.target

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

# systemctl set-default graphical.target
Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment