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
|Category||Requirements, Conventions or Software Version Used|
|System||Red Hat 7 Linux|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – 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.
- The term
runlevelstill exists on RHEL 7 and we can check the current runlevel using
$ runlevel N 5
- 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
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.
- To see a list of all systemd targets, including those which are not currently active on the system, append the
$ systemctl list-units -t target --all
- The System Administrator can activate any of the above targets. For example, by activating
graphical.targetwe will effectively change from runlevel 3 to GUI runlevel 5. To do that we once again use
$ 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
systemctlcommand changed default target by creating a symbolic link into
/etc/systemd/system/default.targetmaking it therefore a default boot target.
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.