How to change runlevel on RHEL 7 Linux

The conventional way used to change the runlevel with /etc/inittab has become obsolete with Red Hat Enterprise Linux version 7. As a result, any Linux system using systemd system management daemon now relies on the systemctl command to change runlevel – or, to be more precise, to change the target. Therefore any edits to the /etc/inittab file will not take effect on RHEL 7.

In this tutorial, you will see how to change the runlevel on Red Hat 7 Linux. This will be done by using systemd. Check out some of the examples below to learn how.

In this tutorial you will learn:

  • How to change the runlevel or systemd target on Red Hat 7 Linux
  • How to view the current runlevel or systemd target
Changing the systemd target / runlevel on Red Hat 7 Linux
Changing the systemd target / runlevel on Red Hat 7 Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Red Hat 7 Linux
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to change runlevel on RHEL 7 Linux




Familiarize yourself with some of the commands below in order to learn how to effectively change the runlevel on RHEL 7. We will explain all of the commands in case you are not familiar with systemd targets or just need a refresher on runlevels in the first place.

  1. The term runlevel still exists on RHEL 7 and we can check the current runlevel using runlevel command:
    $ runlevel
    N 5
    
  2. In regards to RHEL 7, instead of runlevel we talk about systemd targets. For example to list all currently loaded targets we can use the following Linux command:
    $ systemctl list-units -t target
    
    Showing all the currently loaded targets on the system
    Showing all the currently loaded targets on the system

    You can quickly see from the above command why systemd targets on more efficient than runlevels. We can have many systemd targets, all which become active under their own defined conditions. This is much more granular than having only the traditional seven runlevels.

  3. To see a list of all systemd targets, including those which are not currently active on the system, append the --all option.
    $ systemctl list-units -t target --all
    
    Showing all of the active and inactive systemd targets on RHEL 7
    Showing all of the active and inactive systemd targets on RHEL 7
  4. The System Administrator can activate any of the above targets. For example, by activating graphical.target we will effectively change from runlevel 3 to GUI runlevel 5. To do that we once again use systemctl command:
    $ systemctl enable graphical.target --force
    rm '/etc/systemd/system/default.target'
    ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target'
    

    As it is shown on the above output, the systemctl command changed default target by creating a symbolic link into /etc/systemd/system/default.target making it therefore a default boot target.



Closing Thoughts

In this tutorial, we saw how to change the runlevel on Red Hat 7 Linux. As explained here, runlevels have become obsolete and replaced by systemd targets, although the main principles are still the same. The runlevel command is still accessible for legacy purposes, but you should focus on familiarizing yourself with systemd targets instead, as they are more granular and efficient than their predecessor.