[Linux] 设置RHEL默认启动模式(图形界面、命令行)

(1)RHEL6 改变默认启动模式,修改文件/etc/inittab 最后一行 “id:5:initdefault:” 中间的数字,reboot生效

[root@xxx ~]# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
[root@xxx ~]#
[root@xxx ~]#
[root@xxx ~]# runlevel
N 5
[root@xxx ~]#

(2)RHEL7 改变默认启动模式

 相比于RHEL6,RHEL7 的 /etc/inittab 文件中全是注释内容,没有最后一行的配置。查看默认启动模式可以用以下命令

[root@xxx ~]# systemctl get-default
graphical.target   -> 图形界面

如果想修改为命令行模式,执行命令 systemctl set-default multi-user.target  ,reboot生效。
如果想立刻切换到命令行模式可执行 init 3

发布了89 篇原创文章 · 获赞 1 · 访问量 4847

猜你喜欢

转载自blog.csdn.net/wy_hhxx/article/details/103071022