日期:2014-05-16 浏览次数:20710 次
本文链接:http://codingstandards.iteye.com/blog/998235 ? (转载请注明出处)
?
chkconfig命令用于更新和查询系统Linux系统服务的运行级别信息(updates and queries runlevel information for system services)。chkconfig提供一个简单的命令行工具,它可以用来维护/etc/rc[0-6].d目录里面一些符号链接(chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links? in? those? directories.)。chkconfig命令有五种不同的功能(chkconfig has five distinct functions): 添加新的服务(adding new services for management), 删除服务(removing services? from? management), 列出系统服务的当前启动信息(listing the current startup information for services), 更改服务的启动信息(changing the startup information for services), 以及检查特定服务的启动状态(and checking the startup state of a particular service.)。
每个能用chkconfig管理的系统服务脚本需要两个或更多特殊注释行(Each service which should be manageable by chkconfig needs two or more commented? lines? added? to? its? init.d script).? 第一行是该系统服务在哪些运行级别启动、启动优先级和停止优先级(The? first line tells chkconfig what runlevels the service should be started in by default, as well as the start and stop priority levels. If the service should not, by default, be started in? any? runlevels,? a should be used in place of the runlevels list). 第二行是服务的描述信息,可以多行,用反斜杠续行(The second line contains a description for the service, and may be extended across multiple lines with backslash continuation.)下面是一个chkconfig能够是别的注释样本:
?????? # chkconfig: 2345 20 80
?????? # description: Saves and restores system entropy pool for \
?????? #????????????? higher quality random number generation.
?
上面的样本意思是:该脚本将在运行级别2,3,4,5启动,启动优先级为20,停止优先级为80,后面是该服务的描述信息,有两行,多余的空白将会被忽略(This says that the random script should be started in levels 2, 3, 4, and 5, that its start priority should? be 20, and that its stop priority should be 80.? You should be able to figure out what the description says; the \ causes the line to be continued.? The extra space in front of the line is ignored.)
Linux的运行级别:
等级0表示:表示关机
等级1表示:单用户模式
等级2表示:无网络连接的多用户命令行模式
等级3表示:有网络连接的多用户命令行模式
等级4表示:不可用
等级5表示:带图形界面的多用户模式
等级6表示:重新启动
格式:chkconfig
打印chkconfig的使用方法。
?
格式:chkconfig --list
列出所有服务的当前启动信息。
?
格式:chkconfig --list <service>
打印指定系统服务<service>的当前启动信息。
?
格式:chkconfig <service> on
将指定服务<service>系统开机时自动启动。
?
格式:chkconfig <service> off
将指定服务<service>系统开机时不自动启动。
?
[root@jfht ~]# chkconfig
chkconfig 版本 1.3.30.1 - 版权 (C) 1997-2000 Red Hat, Inc.
在 GNU 公共许可的条款下,本软件可以被自由发行。
用法:??? chkconfig --list [name]
???????? chkconfig --add <name>
???????? chkconfig --del <name>
???????? chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities>
[root@jfht ~]#
?
[root@jfht ~]# chkconfig --list
NetworkManager? 0:关闭? 1:关闭? 2:关闭? 3:关闭? 4:关闭? 5:关闭? 6:关闭
acpid?????????? 0:关闭? 1:关闭? 2:启用? 3:启用? 4:启用? 5:启用? 6:关闭
anacron???????? 0:关闭? 1:关闭? 2:启用? 3:启用? 4:启用? 5:启用? 6:关闭
apmd??????????? 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:关闭
avahi-daemon??? 0:关闭? 1:关闭? 2:关闭? 3:启用? 4:启用? 5:启用? 6:关闭
avahi-dnsconfd? 0:关闭? 1:关闭? 2:关闭? 3:关闭? 4:关闭? 5:关闭? 6:关闭
bluetooth?????? 0:关闭? 1:关闭? 2:启用? 3:启用? 4:启用? 5:启用? 6:关闭
capi??????????? 0:关闭? 1:关闭? 2:关闭? 3:关闭? 4:关闭? 5:关闭? 6:关闭
conman????????? 0:关闭? 1:关闭? 2:关闭? 3:关闭? 4:关闭? 5:关闭? 6:关闭
cpuspeed??????? 0:关闭? 1:启用? 2:启用? 3:启用? 4:启用? 5:启用? 6:关闭