CentOS 7 运行级别切换
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. (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
# graphical.target: analogous to runlevel
#
# To set a default target, run:
#
# ln -sf /lib/systemd/system/<target name>.target /etc/systemd/system/default.target
#
id::initdefault: #无效
[sywu@c1-11r2-rac1 etc]$
新版本的运行级别都定义在 /lib/systemd/system下:
[sywu@c1-11r2-rac1 system]$ ls -ltr /lib/systemd/system/runlevel*
lrwxrwxrwx. root root 7月 : /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. root root 7月 : /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. root root 7月 : /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. root root 7月 : /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. root root 7月 : /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. root root 7月 : /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. root root 7月 : /lib/systemd/system/runlevel6.target -> reboot.target
可以针对不同需要设置不同的运行级别:
如设置命令行级别(init 3)方法:
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
设置窗口级别(init 5)方法:
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
-----------------------------分割线-----------------------------
修改系统运行级别:
1、systemd使用比sysvinit的运行级更为自由的target替代。第3运行级用multi-user.target替代。第5运行级用graphical.target替代。runlevel3.target和runlevel5.target分别是指向 multi-user.target和graphical.target的符号链接。
可以使用下面的命令切换到“运行级别3 ”:
systemctl isolate multi-user.target或systemctl isolate runlevel3.target
可以使用下面的命令切换到“运行级别5 ”:
systemctl isolate graphical.target或systemctl isolate runlevel5.target
2、如何改变默认运行级别?
systemd使用链接来指向默认的运行级别。在创建新的链接前,可以通过下面命令删除存在的链接: rm /etc/systemd/system/default.target
默认启动运行级别3 :
ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
默认启动运行级别5 :
ln -sf /lib/systemd/system/graphical.target/etc/systemd/system/default.target
systemd不使用/etc/inittab文件。
-----------------------------分割线-----------------------------
如何查看当前运行级别?
旧的runlevel命令在systemd下仍然可以使用。可以继续使用它,尽管systemd使用 ‘target’ 概念(多个的 ‘target’ 可以同时激活)替换了之前系统的runlevel。
等价的systemd命令是systemctl list-units –type=target
CentOS 7 运行级别切换的更多相关文章
- CentOS 7 运行级别的切换
CentOS 7 运行级别的切换 由命令行级别切换到窗口级别的命令未变:init 5或startx 由窗口级别切换到命令行级别的命令未变:init 3 新版本的运行级别都定义在 /lib/system ...
- CentOS 启动-运行级别
Linux系统的启动过程:内核的引导 > 运行init > 系统初始化 > 建立终端 > 用户登录系统 运行init init 进程是系统所有进程的起点: 主要功能: 准备软件 ...
- centos开机运行级别更改
1.使用命令切换运行级别/目标 # systemctl isolate multi-user.target //切换到运行级别3,该命令对下次启动无影响,等价于telinit 3 # systemct ...
- Centos修改默认运行级别
一.centos默认运行级别 下面是linux的默认运行级别.vim /etc/inittab即可查看. # Default runlevel. The runlevels used are: # - ...
- CentOS7.0小随笔——运行级别
一.Linux运行级别(通用) 0:关机(halt) 1:单用户模式(无需用户名和密码的登录,用于紧急维护系统时用,类似于Windows中的安全模式) 2:不启用网络功能的多用户模式 3:启用网络功能 ...
- Linux运行级别研究(转)
Linux系统中的运行级别 7种运行级别 运行级别(Runlevel)指的是Unix或者Linux等类Unix操作系统的运行模式,不同的运行模式下系统的功能也有所有不同.Linux 系统下通常分为7种 ...
- centos8使用systemctl管理运行级别
一,什么是systemd的target? 1,关于systemd/systemctl的相关知识,请移步到这一篇 https://www.cnblogs.com/architectforest/p/12 ...
- centos7系统运行级别简介
centos7系统运行级别简介我们知道,centos6及之前的版本中,系统运行级别通过/etc/inittab文件进行设置和控制,但在centos7中,对这个文件的设置将不会对系统运行级别产生影响,这 ...
- ubuntu 运行级别initlevel
Linux 系统任何时候都运行在一个指定的运行级上,并且不同的运行级的程序和服务都不同,所要完成的工作和要达到的目的都不同,系统可以在这些运行级之间进行切换,以完成不同的工作.Ubuntu 的系统运行 ...
随机推荐
- RHEL本地yum源
一.挂载本地镜像做yum源(环境:RHEL6.5 64位 VM11) 1.进入/etc/yum.repos.d目录, [root@localhost yum.repos.d]# ls packagek ...
- php Hash Table(三) Hash Table初始化
HashTable初始化,在使用HashTable之前要先执行初始化,下边就看看初始化时都做了什么, Zend/zend_hash.c static const Bucket *uninitializ ...
- Lua 之string库
标准string库 基础字符串函数 string.len(s) 返回一个字符串的长度,例如 string.rep(s, n) 返回一个新的字符串,该字符串是参数s重复n次得到的结果,例如 )) -- ...
- python内置函数每个执行一次
open # with open('log','r') as f: 或者 r=open(filename,r+) with open ('1.txt','r',encoding ...
- 经纬度距离计算Java实现代码
public class test { private static double rad(double d) { return d * Math.PI / 180.0; } public stati ...
- 从零学习storm(一) 环境的安装配置
1.首先 安装zookeeper 2.安装Java环境 3.安装Python 下载python包,编译安装 1.解压 2.configure 3.make ...
- Linux启动流程CentOS6
1.运行级别 0 关机 1 单用户模式,可以想象为Windows的安全模式,主要用与系统修复 2 不完全的命令行模式,不含NFS服务 3 完全的命令行模式,就是标准字符界面 4 系统保留 5 图像模式 ...
- 结果集(result set)解释与用法
解释: 引用自wiki: An SQL result set is a set of rows from a database, as well as metadata about the query ...
- map 与 unordered_map
两者效率对比: #include <iostream> #include <string> #include <map> #include <unordere ...
- 大熊君大话NodeJS之------Stream模块
一,开篇分析 流是一个抽象接口,被 Node 中的很多对象所实现.比如对一个 HTTP 服务器的请求是一个流,stdout 也是一个流.流是可读,可写或兼具两者的. 最早接触Stream是从早期的un ...