一、启动级别
1、查看linux 系统默认启动级别
cat /etc/inittab 
id:3:initdefault: ##可以看出默认为三
2、查看某一服务在各个启动级别上是否启动
[root@localhost ~]# chkconfig --list  nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
3、在Linux中有7种启动级别
分别为: 
#   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) 
各个运行级的详细解释: 
0 为停机,机器关闭。 
1 为单用户模式,就像Win9x下的安全模式类似。 
2 为多用户模式,但是没有NFS支持。 
3 为完整的多用户模式,是标准的运行级。 
4 一般不用,在一些特殊情况下可以用它来做一些事情。例如在笔记本电脑的电池用尽时,可以切换到这个模式来做一些设置。 
5 就是X11,进到X Window系统了。 
6 为重启,运行init 6机器就会重启。
0和6一般不用;
二、 chkconfig
说明 :linux 的所有服务都在 /etc/init.d/  下, 但是 /etc/init.d  是 链接的 /etc/rc.d/init.d
       同样 /etc/rc[0-6].d 都是连接的相应的 /etc/rc.d/rc[0-6].d ,不同启动级别的 rc[0-6].d 中的服务都是 链接的 /etc/init.d 下的相应服务
1、chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。
  语法:
    chkconfig --list [name]
    chkconfig --add name
    chkconfig --del name
    chkconfig [--level levels] name <on|off|reset>
    chkconfig [--level levels] name
    chkconfig 没有参数运行时,显示用法。如果加上服务名,那么就检查这个服务是否在当前运行级启动。如果是,返回true,否则返回false。如果在服务名后面指定了on,off或者reset,那么chkconfi 会改变指定服务的启动信息。on和off分别指服务被启动和停止,reset指重置服务的启动信息,无论有问题的初始化脚本指定了什么。on和off开关,系统默认只对运行级2,3,4,5有效,但是reset可以对所有运行级有效。
    --level选项可以指定要查看的运行级而不一定是当前运行级。
    需要说明的是,对于每个运行级,只能有一个启动脚本或者停止脚本。当切换运行级时,init不会重新启动已经启动的服务,也不会再次去停止已经停止的服务。
2、 chkconfig --list :显示所有运行级系统服务的运行状态信息(on或off)。如果指定了name,那么只显示指定的服务在不同运行级的状态。
    chkconfig --add name:增加一项新的服务。chkconfig确保每个运行级有一项启动(S)或者杀死(K)入口。如有缺少,则会从缺省的init脚本自动建立。
    chkconfig --del name:删除服务,并把相关符号连接从/etc/rc[0-6].d删除。
    chkconfig [--level levels] name <on|off|reset>:设置某一服务在指定的运行级是被启动,停止还是重置。例如,要在3,4,5运行级停止nfs服务,则命令如下:
    chkconfig --level 345 nfs off
3、举例sendmail:
1)cat /etc/inittab
id:3:initdefault:
2)chkconfig --list  sendmail
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
查看连接 :
ll /etc/rc0.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov  5 23:43 K30sendmail -> ../init.d/sendmail
ll /etc/rc1.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov  5 23:43 K30sendmail -> ../init.d/sendmail
ll  /etc/rc2.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov  5 23:43 S80sendmail -> ../init.d/sendmail
ll /etc/rc3.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov  5 23:43 S80sendmail -> ../init.d/sendmail 
ll /etc/rc4.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov  5 23:43 S80sendmail -> ../init.d/sendmail
ll /etc/rc5.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov  5 23:43 S80sendmail -> ../init.d/sendmail
 ll /etc/rc6.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov  5 23:43 K30sendmail -> ../init.d/sendmail
3)chkconfig --del  sendmail
   [root@localhost init.d]# chkconfig --list  sendmail
service sendmail supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add sendmail')
查看连接
[root@localhost init.d]# ll /etc/rc0.d/ |grep sendmail
[root@localhost init.d]# ll /etc/rc0.d/ |grep sendmail
[root@localhost init.d]# ll /etc/rc1.d/ |grep sendmail
[root@localhost init.d]# ll /etc/rc2.d/ |grep sendmail
[root@localhost init.d]# ll /etc/rc3.d/ |grep sendmail
[root@localhost init.d]# ll /etc/rc4.d/ |grep sendmail
[root@localhost init.d]# ll /etc/rc5.d/ |grep sendmail
[root@localhost init.d]# ll /etc/rc6.d/ |grep sendmail
[root@localhost init.d]#  ---》 全为空
4)
[root@localhost init.d]# chkconfig --add  sendmail
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
查看连接:
[root@localhost init.d]# ll /etc/rc0.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc1.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc2.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc3.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc4.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc5.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc6.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail  ----》 相应的服务连接又回来了
5)chkconfig   sendmail  off  --》on和off分别指服务被启动和停止,reset指重置服务的启动信息,无论有问题的初始化脚本指定了什么。on和off开关,系统                                  默认只对运行级3,4,5有效,但是reset可以对所有运行级有效
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off
查看连接:
[root@localhost init.d]# ll /etc/rc0.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc1.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc2.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:36 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc3.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:36 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc4.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:36 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc5.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:36 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc6.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail  ---》全是 "K"
6)chkconfig   sendmail  on 
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
查看连接:
[root@localhost init.d]# ll /etc/rc0.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc1.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc2.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:40 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc3.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:40 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc4.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:40 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc5.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:40 S80sendmail -> ../init.d/sendmail
[root@localhost init.d]# ll /etc/rc6.d/ |grep sendmail
lrwxrwxrwx 1 root root 18 Nov 10 23:33 K30sendmail -> ../init.d/sendmail  --》2,3,4,5 为“S” 其他为 K
7)
chkconfig   sendmail  off 
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@localhost init.d]# chkconfig --level 3  sendmail  on
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:off   3:on    4:off   5:off   6:off
[root@localhost init.d]# chkconfig --level 0  sendmail  on
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:on    1:off   2:off   3:on    4:off   5:off   6:off  --》 看来 得用level on 参数控制 0级别
[root@localhost init.d]# chkconfig   sendmail  off 
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:on    1:off   2:off   3:off   4:off   5:off   6:off  --》 但是这样3 级别关了 0 级别没关掉
[root@localhost init.d]# chkconfig --level 0  sendmail  off
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off  --》 0 级别关掉了 (经验证1,6级别 也是这样的和0级别一样 得用level控制)
8)
[root@localhost init.d]# chkconfig   sendmail  off 
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@localhost init.d]# chkconfig   sendmail  reset
[root@localhost init.d]# chkconfig --list  sendmail
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off --》 reset指重置服务的启动信息 可以对所有运行级有效 (没太懂这个东西reset)

Linux的启动级别的更多相关文章

  1. 修改Linux默认启动级别或模式的方法

    冲动的惩罚: 海阔天空: 在linux系统的7种启动级别,默认为X-Window,类似于Windows的窗口模式. 如何修改或变更linux的默认启动级别或模式呢? 以root身份进入Linux,修改 ...

  2. 修改Linux默认启动级别或模式

    在Linux中有7种启动级别,默认是X-Window,像是Windows的窗口模式,而Linux的操作和配置一般我们都采用输入命令的方式来完成,像DOS操作系统一样,如何让Linux一启动就进入这种模 ...

  3. Linux 开机启动流程

    Linux的开机启动流程 1.开机BIOS自检                                             --> 检查CPU,硬盘等硬件信息 2.MBR[Major ...

  4. CentOS(四)--Linux系统的启动级别

    对于绝大多数Linux程序员来说,进入Linux系统后一般看到的是黑乎乎的界面(开发模式),因为系统如果启动选择开发模式,会减少启动时间,优化内存等.但是通常我们刚安装完Linux系统,然后进去以后是 ...

  5. Linux init 0-6 启动级别

    原文地址:http://blog.sina.com.cn/s/blog_5f8e8d9801010wlr.html 原文地址:[转]Linux init 0-6 启动级别作者:流水清风 init 0- ...

  6. Linux学习笔记之Linux启动级别

    对于绝大多数Linux程序员来说,进入Linux系统后一般看到的是黑乎乎的界面(开发模式),因为系统如果启动选择开发模式,会减少启动时间,优化内存等.但是通常我们刚安装完Linux系统,然后进去以后是 ...

  7. Linux的运行级别和设置开机启动服务的方式

    Linux的运行级别 什么是运行级别呢?简单点来说,运行级别就是操作系统当前正在运行的功能级别.级别是从0到6,具有不同的功能.这些级别定义在/ect/inittab文件中.这个文件是init程序寻找 ...

  8. linux开机启动及运行级别、root密码丢失、单用户模式只读的处理方法

    linux系统启动大致步骤如下:  加电自检-->根据BIOS中的设置从指定的设备启动-->找到设备MBR中的bootloader引导启动系统-->启动kernel-->启动i ...

  9. 『学了就忘』Linux启动引导与修复 — 68、Linux系统运行级别

    目录 1.Linux系统运行级别介绍 2.查看运行级别 3.修改当前系统的运行级别 4.系统默认运行级别 5./etc/rc.d/rc.local文件说明 1.Linux系统运行级别介绍 Linux默 ...

随机推荐

  1. spring的AOP动态代理--JDK代理和CGLIB代理区分以及注意事项

    大家都知道AOP使用了代理模式,本文主要介绍两个代理模式怎么设置以及区别,对原文一些内容进行了引用后加入了自己的理解和更深入的阐述:   一.JDK代理和CGLIB代理的底层实现区别* JDK代理只能 ...

  2. 使用TypeScript拓展你自己的VSCode

    转自:http://www.iplaysoft.com/brackets.html使用TypeScript拓展你自己的VSCode! 0x00 前言在前几天的美国纽约,微软举行了Connect(); ...

  3. 20165332 学习基础和C语言基础调查

    学习基础和c语言基础调查 一.技能学习经验 从小学过很多东西,架子鼓.电子琴.街舞.吉他.书法.美术......爱好也有很多,乒乓球.篮球.唱歌......这么多项技能,要说那一项比大多数人好,还真的 ...

  4. 如何去除pycharm中代码下的波浪线

    Pycharm中新建一个工程,如果不经过配置,在该工程下创建模块写代码,通常是有波浪线的,这样看着很不美观 如何解决这种问题,通常有两种方法 方法一:点击右下角的图标,会出现一个Highlightin ...

  5. eclipse启动Tomcat服务输入http://localhost:8080/报404解决方法

    其实如果Tomcat能够正常启动,而就算输入http://localhost:8080时出现404错误,也不会影响Tomcat作为服务器运行.通过eclipse来启动tomcat会碰到“访问http: ...

  6. IOS-RunTime(刨根问底)

    方法调用 让我们看一下方法调用在运行时的过程(参照前文类在runtime中的表示) 如果用实例对象调用实例方法,会到实例的isa指针指向的对象(也就是类对象)操作.如果调用的是类方法,就会到类对象的i ...

  7. 【spark】常用转换操作:join

    join就表示内连接. 对于内链接,对于给定的两个输入数据集(k,v1)和(k,v2) 根据相同的k进行连接,最终得到(k,(v1,v2))的数据集. 示例 val arr1 = Array((&qu ...

  8. ionic2——开发利器之Visual Studio Code 常用快捷键

    主命令框 F1 或 Ctrl+Shift+P: 打开命令面板.在打开的输入框内,可以输入任何命令,例如: 按一下 Backspace 会进入到 Ctrl+P 模式 在 Ctrl+P 下输入 >  ...

  9. react login page demo

    1. login form import React from "react"; import {Row, Col} from "antd"; import { ...

  10. Report: Disappearing Wetlands Put Planet Life at Risk

    A new report warns that wetlands are disappearing three times faster than the world’s forests, with ...