Redhat7:systemd targets
Previously and Now..
In the old versions of Redhat services that used the SysV or upstart, implemented in a predifined set of run levels that each represented a specific mode of operation. The run levels were numbered from 0-6.
Runlevels have now been replaced with the concept of systemd targets. Each target is represented by a target unit, which end with the .target file extension.
Targets units only purpose is to group together other systemd units, using dependencies. As an example the graphical.target unit is used to start a graphical session, starts the GNOME display Manager (gdm-service).
Redhat7 has a number of predefined targets which are more or less equivalent to the runlevels of RHEL6. To make life easier there a aliases set up to reflect this.
| Comparison of SysV runlevels with systemd targets | |||||
|---|---|---|---|---|---|
| Run Level | Target Units | Description | |||
| 0 | runlevel0.target poweroff.target |
Shutdown the system and power off the system | |||
| 1 | runlevel1.target rescue.target |
Set up a resuce shell | |||
| 2 | runlevel2.target multi-user.target |
Set up a non-graphical multi-user system | |||
| 3 | runlevel3.target multi-user.target |
Set up a non-graphical multi-user system | |||
| 4 | runlevel4.target multi-user.target |
Set up a non-graphical multi-user system | |||
| 5 | runlevel5.target graphical.target |
Set up a graphical multi-user system | |||
| 6 | runlevel6.target reboot.target |
Shut down and reboot the system | |||
Old and New Commands
| Comparison of SysV init commands | |||||
|---|---|---|---|---|---|
| Old Command | New Command | Description | |||
| runlevel | systemctl list-units -- type target | List currently loaded target units | |||
| telinit runlevel | systemctl isolate name.target | Changes the current target | |||
Viewing the default target
systemctl get defaultChange the default target
Previously this would have be done by changing the run level in /etc/inittab
systemctl set-default name.target
Enter Rescue Mode
systemctl rescue
systemctl --no-wall rescue
systemctl isolate rescue.targetEnter Emergency Mode
In the event the resuce mode fails or does not allow the problem to be fixed emergency mode is a last resort. Booting the system is the most minimal environment possible. Mounting the root file system in read only mode, and starting the bare essential services
systemctl emergency
systemctl --no-wall emergency
systemctl isolate emergency.target