CentOS 7 运行级别切换

简介: CentOS 7 之前的版本是通过 /etc/inittab 文件来定义系统运行级别: [sywu@wusuyuan ~]$ cat /etc/centos-release CentOS release 6.


CentOS 7 之前的版本是通过 /etc/inittab 文件来定义系统运行级别:

[sywu@wusuyuan ~]$ cat /etc/centos-release 
CentOS release 6.4 (Final)
[sywu@wusuyuan ~]$ 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:3:initdefault:
[sywu@wusuyuan ~]$ 

CentOS 7 版本不再使用该文件定义系统运行级别,相关运行级别设置无效:

[sywu@c1-11r2-rac1 etc]$ cat /etc/centos-release 
CentOS Linux release 7.0.1406 (Core) 
[sywu@c1-11r2-rac1 etc]$ 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 /etc/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 set a default target, run:
#
# ln -sf /lib/systemd/system/<target name>.target /etc/systemd/system/default.target
#
id:3:initdefault:  #无效
[sywu@c1-11r2-rac1 etc]$ 

新版本的运行级别都定义在 /lib/systemd/system下:

[sywu@c1-11r2-rac1 system]$ ls -ltr /lib/systemd/system/runlevel*
lrwxrwxrwx. 1 root root 13 7月  30 14:22 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 15 7月  30 14:22 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 7月  30 14:22 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 7月  30 14:22 /lib/systemd/system/runlevel6.target -> reboot.target

可以针对不同需要设置不同的运行级别:
如设置命令行级别方法:

ln -sf /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target
或
ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
或
systemctl set-default multi-user.target

设置窗口级别方法:

ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
或
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
或
systemctl set-default graphical.target

 

http://www.cnblogs.com/lanston/p/3880577.html?utm_source=tuicool&utm_medium=referral

相关文章
|
6月前
|
Linux Shell 数据安全/隐私保护
centos 开机启动流程、开机运行级别
centos 开机启动流程、开机运行级别
|
安全 网络协议 Ubuntu
[CentOS,LISTEN,运行级别,NFS,Debian]强化Linux安全的10个技能
  1.找出不必要的服务   很明显,服务器上跑的服务,并不是每个都有用的。强烈建议检查并关掉不需要的服务,从而减少风险(多跑一个服务,就可能多几个漏洞)。   查询运行在runlevel 3的服务列表:   [afei@afei ~]# /sbin/chkconfig --list |grep '3:on'
163 0
|
网络协议 关系型数据库 MySQL
centOS安装telnet服务和xinetd服务和iptables和linux运行级别
默认在centOS最小安装下没有安装telnet服务的,需要自己安装(root权限): 错误: [root@localhost log]# telnet 192.168.10.56 27017 -bash: telnet: command not found 1:查看系统版本信息(centos7): [root@localhost log]# cat /etc/issue
4940 0
|
6天前
|
存储 分布式计算 Hadoop
Centos7.9安装kerberos
Centos7.9安装kerberos
55 25
|
1天前
|
存储 Shell 网络安全
Centos7.9安装openldap
Centos7.9安装openldap
32 16
|
2天前
|
数据可视化 Linux 应用服务中间件
Centos7.9安装phpldapadmin
Centos7.9安装phpldapadmin
33 15
|
5天前
|
网络协议 Java 应用服务中间件
centos7环境下tomcat8的安装与配置
本文介绍了在Linux环境下安装和配置Tomcat 8的详细步骤。首先,通过无网络条件下的文件交互软件(如Xftp 6或MobaXterm)下载并解压Tomcat安装包至指定路径,启动Tomcat服务并测试访问。接着,修改Tomcat端口号以避免冲突,并部署Java Web应用项目至Tomcat服务器。最后,调整Linux防火墙规则,确保外部可以正常访问部署的应用。关键步骤包括关闭或配置防火墙、添加必要的端口规则,确保Tomcat服务稳定运行。