当前位置:   首页安装配置Linux 使用init命令实现关机,重启,切换模式

Linux 使用init命令实现关机,重启,切换模式

发布日期:2022-03-14 19:09 | 文章来源:CSDN

Linux init命令 详解

reboot可能是每个用过Linux的人都知道的命令,但有一个命令“init”才是命令中的精英。

最近有个同事学习安装了CentOS,明明安装的是带桌面的系统,但是启动后进入了命令行模式,搞不定了问到我,我执行了一下“init 5”,界面就出来了,那哥们顿时心生佩服,感觉好神奇。其实计算机这东西就是这样子,不会的就感觉好神奇,当你会了,也就是那么回事。

Linux有个文件 /etc/inittab

# inittab    This file describes how the INIT process should set up  
#        the system in a certain run-level.  
#  
# Author:    Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>  
#        Modified for RHS Linux by Marc Ewing and Donnie Barnes  
#  
# Default runlevel. The runlevels used by RHS 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:   

说明

0是关机
1是单用户
2是多用户,不联网
3是多用户
4是不使用的
5是xwindows,也就是有界面的
6是重启

用法

init命令很简单。直接输入init + 你想要的模式 回车就行。

比如 输入 : init 0 就是关机

init 3 就是切换到多用户
init 5 就是切换到界面
init 6 就是重启

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

联系我们
关于使用场景和技术架构的更多咨询,请联系我们的销售和技术支持团队。
Yingsoo Host

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部