Runlevel Rhel-7
CentOS 7 / RHEL 7 Check The Current Runlevel
You still can use “runlevel” command to check the current level, also can use another two commands.
1
2 3 |
systemctl get-default
Or ll /etc/systemd/system/default.target |
[root@itsprite Desktop]# systemctl get-default
graphical.target
1
2 |
[root@itsprite Desktop]# ll /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 36 Nov 27 09:31 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target |
CentOS 7 / RHEL 7 Supported Runlevel
Using the followding command to get out the available runlevel, type:
1
|
systemctl list-units --type=target
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[root@itsprite Desktop]# systemctl list-units --type=target
UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System cryptsetup.target loaded active active Encrypted Volumes getty.target loaded active active Login Prompts graphical.target loaded active active Graphical Interface local-fs-pre.target loaded active active Local File Systems (Pre) local-fs.target loaded active active Local File Systems multi-user.target loaded active active Multi-User System network.target loaded active active Network nfs.target loaded active active Network File System Server paths.target loaded active active Paths printer.target loaded active active Printer remote-fs.target loaded active active Remote File Systems slices.target loaded active active Slices sockets.target loaded active active Sockets sound.target loaded active active Sound Card swap.target loaded active active Swap sysinit.target loaded active active System Initialization timers.target loaded active active Timers LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. |
OR you can use “ll -l /lib/systemd/system/runlevel*.target” to get the runlevel that CentOS 7 system support.
1
2 3 4 5 6 7 8 |
[root@itsprite Desktop]# ls -l /lib/systemd/system/runlevel*.target
lrwxrwxrwx. 1 root root 15 Nov 27 09:18 /lib/systemd/system/runlevel0.target -> poweroff.target lrwxrwxrwx. 1 root root 13 Nov 27 09:18 /lib/systemd/system/runlevel1.target -> rescue.target lrwxrwxrwx. 1 root root 17 Nov 27 09:18 /lib/systemd/system/runlevel2.target -> multi-user.target lrwrwxrwx. 1 root root 17 Nov 27 09:18 /lib/systemd/system/runlevel3.target -> multi-user.target lrwxrwxrwx. 1 root root 17 Nov 27 09:18 /lib/systemd/system/runlevel4.target -> multi-user.target lrwxrwxrwx. 1 root root 16 Nov 27 09:18 /lib/systemd/system/runlevel5.target -> graphical.target lrwxrwxrwx. 1 root root 13 Nov 27 09:18 /lib/systemd/system/runlevel6.target -> reboot.target |
CentOS 7 / RHEL 7 Set Default Runlevel
you need to edit the “/etc/inittab” file to set the defatult runlevel in Centos 6.x system, but now the inittab file is no longer used in centos 7 system, and systemd uses “targets” instead of runlevels, there are two main targets: multi-user.target (runlevel 3) and graphical.target( runlevel 5), to set a defalut target or default runlevel, run the following command:
1
|
ln -sf /lib/systemd/system/<target name>.target /etc/systemd/system/default.target
|
1
|
ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
|
Or you can use a systemctl command to set default runlevel, type:
1
|
systemctl set-default multi-user.target
|
1
|
reboot
|
CentOS 7 / RHEL 7 Switch Current Runlevel
If you wanna to switch the current runlevel to another, and also do not want to reboot the system, such as, switching the mult-user.target level to graphical.target level immediately, issue the following command:
1
2 3 |
systemctl isolate graphical.target
OR systemctl isolate runlevel5.target |
1
2 3 |
systemctl isolate mult-user.target
OR systemctl isolate runlevel3.target |
Comments
Post a Comment