Changing runlevels with systemctl

This is an RHCE question for sure. With the wholesale replacement of the old System V init system with systemd many things have changed, including what were previously known as “run levels”. More below.

The old AT&T Unix System V init system has had a long career in Unix and Unix-like systems. It is still used by many, including FreeBSD. But with the adoption of systemd on Red Hat systems it only continues to exist as part of a legacy compatibility layer in current releases.

One of the first things I learned how to do on a Unix system was change the default start from graphical to console. Back in the day Sun was keen to have everyone enjoy the wonders of what it called the “Common Desktop Environment”, or CDE. This was an early graphical desktop that was long on PR and short on actual functionality. For most of us its main advantage was that you could open up and view multiple terminals on the server console at the same time. Not much of a benefit, of course, when the server console was hundreds of miles away in a data center somewhere (at least not until we discovered VNC, but that’s another story).

But the CDE used memory. Not much, but back then we didn’t have more than 2 GB of RAM on most servers — so every little bit counted. Besides, real men (or women) don’t run graphical environments on servers. It’s just not done (or shouldn’t be).

On most systems following the System V model, including Linux before systemd, you had to change a line in /etc/inittab from run level 5 (graphical mode) to 3 (“multi user, with network” mode).

That file was one of the first things to go in the re-engineering of Linux around systemd, however.

Have no fear though, because there is actually a correct way to accomplish the same end using systemd’s systemctl command.

Instead of run level 3 we now have systemd’s “”. The new equivalent to run level 5 is the “” (systemd actually provides a much wider variety of modes that System V did run levels, but those are mostly used by system level services).

To change the default start from graphical to console you would issue this command:

systemctl isolate

To change back to graphical, you’d do this:

systemctl isolate

Note you will only experience the change if you do this from a graphical session on the box.

None of the above will change the, the one that loads when the machine reboots.

To change the to the, type this:

systemctl set-default

Changing it back to graphical is as easy as:

systemctl set-default

How do you know what the default target is at any given time? Just do this:

systemctl get-default

For lots more information on systemd, see its page on the Fedora Project Wiki (systemd was invented by a Red Hat employee).

This entry was posted in System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).