Linux修改运行级别:inittab is no longer used when using systemd.

现象:

  • 不管是输入命令 init 3 或者 init5 ,重启后都是直接进入图形界面
  • vim /etc/inittab 查看,内容如下:
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target

解决方案:

  • 英文注释写的很清楚,大致就是用systemctl set-default   和 systemctl get-default 取代数字级别
  • # 查看当前运行级别
    systemctl get-default
    
    # 设置当前运行级别为3 (开机为命令行模式)
    systemctl set-default multi-user.target
    
    # 设置当前运行级别为5 (开机为图形界面)
    systemctl set-default graphical.target

     

你可能感兴趣的:(linux)