This post explains how to display, change, and switch target(runlevel) in systemd on a CentOS/RHEL 7 machine.
Display Target (runlevel)
1. To display the default target unit, run the below command:
# systemctl get-default graphical.target
2. To list all currently loaded target units, run the below command:
# systemctl list-units --type target
3. By default, the systemctl list-units command displays only active units. To list all loaded units regardless of their state, run the above command with the –all or -a command line option:
# systemctl list-units --type target --all
Change default target
To change the default target, run the below command:
# systemctl set-default [new_target]
# systemctl set-default multi-user.target
Replace [new_target] with multi-user.target or graphical.target.
- multi-user.target >> runlevel 3
- graphical.target >> runlevel 5
While the system is running, you can switch the target/(runlevel), which means only services as well as units defined under that target will run on the system.
1. To switch to runlevel 3, run the below command:
# systemctl isolate multi-user.target
2. To switch the system to runlevel 5, run the below command:
# systemctl isolate graphical.target
3. Refer man systemctl for more details:
# man systemctl