马丁传奇

导航

centos7修改默认运行级别

一、centos6是通过修改/etc/inittab来修改默认运行级别的:

[root@localhost ~]# vim /etc/inittab

 

二、在centos7下运行vim /etc/inittab结果如下:

[root@centos7 ~]# cat /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  相当于 runlevel 3
# graphical.target: analogous to runlevel 5   相当于 runlevel 5
#
# To view current default target, run:
# systemctl get-default --------------------- 获取当前运行级别
#
# To set a default target, run:
# systemctl set-default TARGET.target ------- 设置运行级别
#

可以看到,里面除了注释,什么也没有,并没有centos6中设置默认运行级别的方式。


三、CentOS 7.x 查看默认运行级别的方式为

方式1
[root@centos7 ~]# runlevel
5 3


方式2
[root@centos7 ~]# systemctl get-default
multi-user.target

 

四、CentOS 7.x 设置默认运行级别命令:
       [root@centos7 ~]# systemctl set-default TARGET.target

[root@centos7 ~]# systemctl set-default multi-user.target --------> 设置为runlevel 3
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

 

五、CentOS 7.x 运行级别 TARGET.target 对应表

init级别

systemctl target
0 shutdown.target
1 emergency.target
2 rescure.target
3 multi-user.target
4
5 graphical.target
6

 

posted on 2019-07-26 23:00  马丁传奇  阅读(638)  评论(0编辑  收藏  举报