linux's docs

19.3.0: 服务管理-chkconfig


1. 工具:chkconfig

作用:查询或修改各runlevel的系统服务信息
语法:chkconfig [参数 [内容]] [name] <on|off|reset|resetpriorties>

  • man page description
    chkconfig [--list] [--type type][name]
    chkconfig --add name
    chkconfig --del name
    chkconfig --override name
    chkconfig [--level levels] [--type type] name <on|off|reset|resetpriorities>
    chkconfig [--level levels] [--type type] name

  • 常用用法
    chkconfig --list [servicename]
    chkconfig --add/del servicename (可自定义启动脚本)
    chkconfig --level 345 servicename on/off

用法示例:

# 查看NetworkMnager服务开启状态
chkconfig --list NetworkManager
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

# 关闭NetworkMnager服务
chkconfig --level 2345 NetworkManager off
chkconfig --list NetworkManager
NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off

# 不指定servicename的时候默认显示全部服务
chkconfig
NetworkManager  0:off   1:off   2:on    3:on    4:on    5:on    6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
auditd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
blk-availability        0:off   1:on    2:on    3:on    4:on    5:on    6:off
......

# 重新开启NetworkMnager服务
chkconfig --level 2345 NetworkManager on

Contents