Note: This is an RHCSA 7 exam objective.
In the old days
Before Systemd, there were the following runlevels:
- 1, single: maintenance level,
- 2: level without network resources (NFS, etc),
- 3: multi-user level without graphical interface,
- 5: multi-user level with graphical interface.
Note: The default run level was set in the /etc/inittab file.
To get the current run level with the old way, type:
# runlevel
To change the current run level (where X is the run level), type:
# init X
Note: As seen before, levels 0 and 6 were respectively used for halting a system and for rebooting it.
Current State
With Systemd, new commands are available:
- systemctl rescue: to move to single user mode/maintenance level with mounted local file systems,
- systemctl emergency: to move to single user mode/maintenance with only /root mounted file system,
- systemctl isolate multi-user.target: to move to multi-user level without graphical interface (equivalent to previous run level 3),
- systemctl isolate graphical.target: to move to multi-user level with graphical interface (equivalent to previous run level 5),
- systemctl set-default graphical.target: to set the default run level to multi-user graphical mode,
- systemctl get-default: to get the default run level.
Additional Resources
Make sure you visit the Systemd page.
You can also watch Ralph Nyberg‘s video about Systemd targets (6min/2015).
To boot into a systemd target from the grub menu, append to the kernel line for example:
systemd.unit=graphical.target
Interesting. Thanks.
Strange
In case of command “systemctl rescue” I get info:
“…Welcome to emergency mode! After logging in, type “journalctl -xb” to view…”
and all file systems are mounted.
Maybe the rescue mode is accessed only via rd.break parameter during boot?
My sytemctl has built-in command completion, so I can type systemctl, hit TAB twice, and it shows all the possible actions, like rescue or isolate graphical.target.
When I type systemctl set-default and TAB, there are about 70 different runlevels!!! I’m glad the exam just focuses on the more common ones.
What’s more, if you’re an old-school admin, systemd supports the traditional initd runlevels. For instance, if I type…
systemctl isolate runlevel6.target
the system will reboot.
Note I think bash-complete needs to be installed to ensure tab works.
No. This isn’t bash completion. I’m talking TAB completion for various utilities, like nmcli, and systemctl. I have a VM running the CentOS 7 minimal install. Bash completion works fine, but not the individual utilities.
BTW, the package is called bash-completion. There is also a package called bash-completion-extras. That also does not install those utilities. Everything works just fine on the default install.
Oh, man, did I ever get it wrong on that one. You’re correct, you need bash-completion and bash-completion-extras. I installed them on a VM running the CentOS 7 minimal install, but it still didn’t work.
After some research, it turns out that completion is a bunch of shell scripts – I thought it was a daemon. It didn’t work because the main script is sourced in the user’s start-up scripts. Simply logging out and back in again (no restart) got it all working.
Your welcome. I only used bash-completion, and every time I did a new VM, I used a minimal-install, just in-case there may be something like that on the exam.