00. 目录
01. 命令概述
chkconfig命令检查、设置系统的各种服务。这是Red Hat公司遵循GPL规则所开发的程序,它可查询操作系统在每一个执行等级中会执行哪些系统服务,其中包括各类常驻服务。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。
02. 命令格式
用法:
chkconfig [--list] [--type <type>] [name]
chkconfig --add <name>
chkconfig --del <name>
chkconfig --override <name>
chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities>
03. 常用选项
必要参数
--add 开启指定的服务程序
--del 关闭指定的服务程序
--list 列出chkconfig所知道的所有服务
选择参数
--level<代号> 设置服务程序的等级代号,它是一串0~7的数字,如“-level35”代表指定运行等级3和5
--help 显示帮助信息
--version 显示版本信息
等级代号说明:
- 等级0表示:表示关机
- 等级1表示:单用户模式
- 等级2表示:无网络连接的多用户命令行模式
- 等级3表示:有网络连接的多用户命令行模式
- 等级4表示:不可用
- 等级5表示:带图形界面的多用户模式
- 等级6表示:重新启动
04. 参考示例
4.1 列出所有的系统服务
[deng@localhost ~]$ chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
vmware-tools 0:关 1:关 2:开 3:开 4:开 5:开 6:关
vmware-tools-thinprint 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[deng@localhost ~]$
4.2 增加network服务
[root@localhost ~]# chkconfig --add network
–add 增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据
4.3 删除network服务
[root@localhost ~]# chkconfig --del network
–del 删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据
4.4 设置network在运行级别为2、3、4、5的情况下都是on(开启)的状态
[root@localhost ~]# chkconfig --level 2345 network on
4.5 设置network在运行级别为2、3、4、5的情况下都是off(关闭)的状态
[root@localhost ~]# chkconfig --level 2345 network off
4.6 查看network服务状态
[root@localhost ~]# chkconfig --list network
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@localhost ~]#
4.7 设置network在运行级别为2、3、4、5的情况下都是on(开启)的状态
[root@localhost ~]# chkconfig network on
[root@localhost ~]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
vmware-tools 0:关 1:关 2:开 3:开 4:开 5:开 6:关
vmware-tools-thinprint 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@localhost ~]#
4.8 设置network在运行级别为2、3、4、5的情况下都是off(关闭)的状态
[root@localhost ~]# chkconfig network off
[root@localhost ~]# chkconfig --list network
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
network 0:关 1:关 2:关 3:关 4:关 5:关 6:关
[root@localhost ~]#