How to Change RunLevel on CentOS 7 / RHEL 7

Old method to change the runlevel via /etc/inittab in Redhat Enterprise Linux version and CentOS server has become obsolete on RHEL 7 and CentOS 7. This latest Linux operating system uses systemd system management daemon and relies on systemctl command in order to change the runlevel. RunLevel is set with linking to /etc/systemd/system/default.target. Please make sure you have already install Gnome GUI before you proceed to change runlevel.

1. Check the current runlevel :

# runlevel
N 3

or

# systemctl get-default
multi-user.target

2. We can display the default.target by using list command :

# ll /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 37 Sep  1  2014 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target

3. For example to list all currently loaded 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
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.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

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

14 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

4. Type the following command to change the RunLevel to Graphical-login :

# systemctl set-default graphical.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target'

5. Verify the changed runlevel :

# runlevel
N 5

or

# systemctl get-default
graphical.target

6. Reboot the server to login to GNOME gui.

redhat-banner

How to Switching or Changing Between Different Runlevels on Linux

linuxThe runlevel is a software configuration of the system which allows only a selected group of processes to exist. Usually runlevel 0, 1 and 6 are the same and reserved for the following purposes :

0 – halt
1 – single mode
6 – reboot

Meanwhile runlevel 2,3,4 and 5 used for the following :

2 – Multi-User Mode
3 – Multi-User Mode with Networking
4 – Not used/User-definable
5 – Start the system normally with appropriate display manager. ( with GUI )

How to Check and Display Runlevel on Unix or Linux System

In this post, i will show two method to switching or changing between different runlevels on linux. The steps has been tested on CentOS 6.2.

Method 1. Changing run level temporarily without reboot :

In order to change the run level immediately without reboot, you can use init command. Assumed that you are currently in the default run level 3 and want to switch to run level 1 which is will enter single user mode, execute “init 1” :

[root@centos62 ~]# init 1

To shutdown the system, execute “init 0” :

[root@centos62 ~]# init 0

To reboots the system, execute “init 6” :

[root@centos62 ~]# init 6

Please note that above command is not permanent and the system will return to default run level after reboot.

Method 2. Changing the run level permanently :

[root@centos62 ~]# vi /etc/inittab

Let assumed the default run level is 3.

#
id:3:initdefault:

Change the initdefault to 5 as below :

#
id:5:initdefault:

How to Check and Display Runlevel on Unix or Linux System

This example shows the correct ways to check run level on unix or linux server. The runlevel is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init command/process for each of these runlevels are defined in the /etc/inittab file. Usually runlevel 0, 1 and 6 are the same and reserved for the following purposes :

0 – halt
1 – single mode
6 – reboot

Meanwhile runlevel 2,3,4 and 5 used for the following :

2 – Multi-User Mode
3 – Multi-User Mode with Networking
4 – Not used/User-definable
5 – Start the system normally with appropriate display manager. ( with GUI )

1. Check and display runlevel using “who” command :

[root@centos62 ~]# who -r
         run-level 3  2012-07-07 09:58

2. Check and display current and previous system runlevel using “runlevel” command :

[root@centos62 ~]# runlevel
N 3

How to Switching or Changing Between Different Runlevels on Linux