• Red Hat Enterprise Linux 7

问题

  • How do I set the default runlevel to 3 in RHEL 7?
  • How do I set the default boot target to text only?
  • How do I set the default runlevel to 5 in RHEL 7?
  • How do I boot to graphical mode by default in RHEL 7?
  • How do i set the default boot target to graphical in RHEL 7?

决议

  • Systemd has replaced sysVinit as the default service manager in RHEL 7. Some of the sysVinit commands have been symlinked to their RHEL 7 counterparts, however this will eventually be deprecated in favor of the standard systemd commands in the future.

SysVinit to systemd conversions

Sysvinit Runlevel

Systemd Target

What does it do?

0

runlevel0.target, poweroff.target

System halt/shutdown

1, s, single

runlevel1.target, rescue.target

Single-user mode

2, 4

runlevel2.target, runlevel4.target, multi-user.target

User-defined/Site-specific runlevels. By default, identical to 3.

3

runlevel3.target, multi-user.target

Multi-user, non-graphical mode, text console only

5

runlevel5.target, graphical.target

Multi-user, graphical mode

6

runlevel6.target, reboot.target

Reboot

emergency

emergency.target

Emergency mode

Changing runlevels/targets

  • To set a default runlevel/target in systemd, use the following syntax:
    Raw
    systemctl set-default <desired>.target
  • If the server is in rescue mode or in a chrooted environment, the default target can be set with the following command syntax:
    Raw
    ln -sf /lib/systemd/system/<desired>.target /etc/systemd/system/default.target
  • To change runlevels on the fly:
    Raw
    systemctl isolate [multi-user.target | graphical.target]