Linux chkconfig命令

Linux chkconfig命令:为系统服务更新和查询运行级别信息。

Linux chkconfig命令 功能描述

使用chkconfig命令可以为系统服务更新和查询运行级别信息。用来查看和设置开机自动启动或停止服务,使用chkconfig命令不会立即启动或停止一项服务(如果要立即启动服务用service命令)。

Linux chkconfig命令 语法

chkconfig [选项] [服务名] [on|off|reset|resetpriorities]

命令中各选项的含义如表所示。

chkconfig命令选项含义

Linux chkconfig命令 示例

查看不同运行等级中各项服务的开机运行情况

[root@rhel ~]# chkconfig --list
NetworkManager  0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
abrt-ccpp       0:关闭  1:关闭  2:关闭  3:启用  4:关闭  5:启用  6:关闭
abrtd          0:关闭  1:关闭  2:关闭  3:启用  4:关闭  5:启用  6:关闭
acpid          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
atd            0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
auditd          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
autofs          0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
blk-availability   0:关闭  1:启用  2:启用  3:启用  4:启用  5:启用  6:关闭
bluetooth       0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
certmonger      0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
cpuspeed       0:关闭  1:启用  2:启用  3:启用  4:启用  5:启用  6:关闭
crond          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
cups          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
dnsmasq       0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
firstboot       0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
haldaemon      0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
htcacheclean    0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
httpd          0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
ip6tables       0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
iptables       0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
irqbalance      0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
kdump        0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
lvm2-monitor   0:关闭  1:启用  2:启用  3:启用  4:启用  5:启用  6:关闭
mdmonitor     0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
  ........................(省略)

列出crond服务在各个运行级别上的开机自动运行情况

[root@rhel ~]# chkconfig --list crond
crond     0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

在运行级别3、4上让crond服务开机自动停止

[root@rhel ~]# chkconfig --level 34 crond off

在运行级别3、4、5上让crond服务开机自动启动

[root@rhel ~]# chkconfig --level 345 crond on

对crond服务设置没有选择运行级别的开机自动启动

[root@rhel ~]# chkconfig crond on

让telnet服务开机自动启动

[root@rhel ~]# chkconfig telnet on

让telnet服务开机自动停止

[root@rhel ~]# chkconfig telnet off

添加一个由chkconfig管理的httpd服务

[root@rhel ~]# chkconfig --add httpd

删除由chkconfig管理的httpd服务

[root@rhel ~]# chkconfig --del httpd

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程