linux启动时的runlevel

来源:互联网 发布:unity3d玻璃材质包 编辑:程序博客网 时间:2024/03/29 00:14

操作需要root权限

[html] view plain copy
  1. [chen@localhost ~]$ vim /etc/inittab   

可以看到:

[html] view plain copy
  1. #  
  2. # System initialization is started by /etc/init/rcS.conf  
  3. #  
  4. # Individual runlevels are started by /etc/init/rc.conf  
  5. #  
  6. # Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf  
  7. #  
  8. # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,  
  9. # with configuration in /etc/sysconfig/init.  
  10. #  
  11. # For information on how to write upstart event handlers, or how  
  12. # upstart works, see init(5), init(8), and initctl(8).  
  13. #  
  14. # Default runlevel. The runlevels used are:  
  15. #   0 - halt (Do NOT set initdefault to this)  
  16. #   1 - Single user mode  
  17. #   2 - Multiuser, without NFS (The same as 3, if you do not have networking)  
  18. #   3 - Full multiuser mode  
  19. #   4 - unused  
  20. #   5 - X11  
  21. #   6 - reboot (Do NOT set initdefault to this)  
  22. #   
  23. id:5:initdefault:  

最后一行就是默认的缺省运行级别

修改该值可以永久使用此运行级别

若要临时改变运行级别可以:

当在runlevel 3运行时,要临时切换到runlevel 5时,可以使用init 5来切换。

Linux系统有7个运行级别(runlevel)

Linux系统有7个运行级别(runlevel)
运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动
运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆
运行级别2:多用户状态(没有NFS)
运行级别3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式
运行级别4:系统未使用,保留
运行级别5:X11控制台,登陆后进入图形GUI模式
运行级别6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动

运行级别的原理:
1。在目录/etc/rc.d/init.d下有许多服务器脚本程序,一般称为服务(service)
2。在/etc/rc.d下有7个名为rcN.d的目录,对应系统的7个运行级别
3。rcN.d目录下都是一些符号链接文件,这些链接文件都指向init.d目录下的service脚本文件,命名规则为K+nn+服务名或S+nn+服务名,其中nn为两位数字。
4。系统会根据指定的运行级别进入对应的rcN.d目录,并按照文件名顺序检索目录下的链接文件
     对于以K开头的文件,系统将终止对应的服务
     对于以S开头的文件,系统将启动对应的服务
5。查看运行级别用:runlevel
6。进入其它运行级别用:init N
7。另外init0为关机,init 6为重启系统


0 0
原创粉丝点击