博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS 7 运行级别切换
阅读量:6173 次
发布时间:2019-06-21

本文共 3062 字,大约阅读时间需要 10 分钟。

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 /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.targetlrwxrwxrwx. 1 root root 15 7月  30 14:22 /lib/systemd/system/runlevel0.target -> poweroff.targetlrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel2.target -> multi-user.targetlrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel3.target -> multi-user.targetlrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel4.target -> multi-user.targetlrwxrwxrwx. 1 root root 16 7月  30 14:22 /lib/systemd/system/runlevel5.target -> graphical.targetlrwxrwxrwx. 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

转载于:https://www.cnblogs.com/softidea/p/6677832.html

你可能感兴趣的文章
第六章:Hystrix监控面板及数据聚合(Turbine)
查看>>
MyEclipse Servers视窗出现“Could not create the view: An unexpected exception was thrown”错误解决办法...
查看>>
面包屑的由来
查看>>
伪类和伪元素
查看>>
jquery
查看>>
ionic+js+html5 飞行射击游戏
查看>>
c++ stl vector erase 操作
查看>>
17年2月末用时两天的(按周统计订单金额)
查看>>
SSL工作原理
查看>>
android BitmapFactory的OutOfMemoryError: bitmap ...
查看>>
微信开发-错误码
查看>>
Day 3:模块结构和布局
查看>>
PWP+Nginx 集成环境下载
查看>>
Spring4 版 eventbus 事件通信 事件驱动 介绍
查看>>
浅析hadoop 简历就写这个了
查看>>
【整理】RabbitMQ publish方法中的immediate和mandatory属性
查看>>
JAVA CAS原理深度分析
查看>>
JQuery的表单验证
查看>>
javascript 鼠标选中部分值的获取 (有文本框)
查看>>
权限模型
查看>>