How to Change RunLevel on CentOS 7 / RHEL 7

In Linux operating systems, specifically Redhat Enterprise Linux (RHEL) and CentOS, the method to change the runlevel via /etc/inittab has become obsolete as of RHEL 7 and CentOS 7. These latest versions of Linux operating systems have adopted the systemd system management daemon and rely on the systemctl command to change the runlevel. The runlevel is set by linking to /etc/systemd/system/default.target. Before proceeding to change the runlevel, it is essential to ensure that the Gnome GUI is already installed.

This tutorial will guide you through the process of checking the current runlevel, displaying the default.target, listing all currently loaded targets, changing the runlevel to Graphical-login, verifying the changed runlevel, and finally rebooting the server to login to the GNOME gui.

Checking the Current Runlevel

To check the current runlevel, you can use either of the following commands:

# runlevel
N 3

or

# systemctl get-default
multi-user.target

Displaying the Default.target

You can display the default.target by using the 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

Listing All Currently Loaded Targets

To list all currently loaded targets, use the following command:

# systemctl list-units -t target

This command will display a list of all currently loaded targets, including their load status, active status, and sub status.

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'.

Changing the RunLevel to Graphical-login

To change the RunLevel to Graphical-login, use the following command:

# systemctl set-default graphical.target

This command will remove the current default.target and create a symbolic link to the graphical.target.

See also  How to Install and Configure EPEL Repository on CentOS 6.2

Verifying the Changed Runlevel

To verify that the runlevel has been changed, you can use either of the following commands:

# runlevel
N 5

or

# systemctl get-default
graphical.target

Rebooting the Server

Finally, to apply the changes, reboot the server. After rebooting, you will be able to login to the GNOME gui.

Commands Mentioned

  • # runlevel – Checks the current runlevel
  • # systemctl get-default – Gets the default runlevel
  • # ll /etc/systemd/system/default.target – Displays the default.target
  • # systemctl list-units -t target – Lists all currently loaded targets
  • # systemctl set-default graphical.target – Changes the RunLevel to Graphical-login
See also  How to Grep Multiples Lines and using Specific Keyword on Linux

Conclusion

Changing the runlevel in RHEL 7 and CentOS 7 involves a series of steps that include checking the current runlevel, displaying the default.target, listing all currently loaded targets, changing the runlevel to Graphical-login, verifying the changed runlevel, and finally rebooting the server to login to the GNOME gui. This process is made possible by the systemd system management daemon and the systemctl command.

Remember, before proceeding to change the runlevel, it is essential to ensure that the Gnome GUI is already installed.

See also  How to Install and Configure Squid Proxy Server in CentOS 5.5

By following this tutorial, you should now be able to change the runlevel on your RHEL 7 or CentOS 7 server with ease.

FAQ

  1. What is the command to check the current runlevel?

    You can use either “# runlevel” or “# systemctl get-default” to check the current runlevel.

  2. How can I display the default.target?

    You can display the default.target by using the list command: “# ll /etc/systemd/system/default.target”.

  3. What is the command to list all currently loaded targets?

    You can list all currently loaded targets by using the command: “# systemctl list-units -t target”.

  4. How can I change the RunLevel to Graphical-login?

    You can change the RunLevel to Graphical-login by using the command: “# systemctl set-default graphical.target”.

  5. What is the command to verify the changed runlevel?

    You can verify the changed runlevel by using either “# runlevel” or “# systemctl get-default”.

Comments

Leave a Reply

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