一天一条Linux指令-chkconfig

用途说明

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:关闭
crond           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
cups            0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
dnsmasq         0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
dund            0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
firstboot       0:关闭  1:关闭  2:关闭  3:启用  4:关闭  5:启用  6:关闭
gpm             0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
haldaemon       0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
hidd            0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
hplip           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
ip6tables       0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
ipmi            0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
iptables        0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
irda            0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
irqbalance      0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
isdn            0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
jexec           0:启用  1:启用  2:启用  3:启用  4:启用  5:启用  6:启用
kdump           0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
kudzu           0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
lvm2-monitor    0:关闭  1:启用  2:启用  3:启用  4:启用  5:启用  6:关闭
mcstrans        0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
mdmonitor       0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
mdmpd           0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
messagebus      0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
microcode_ctl   0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
multipathd      0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
mysql           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
netconsole      0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
netfs           0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
netplugd        0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
network         0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
nfs             0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
nfslock         0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
nscd            0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
ntpd            0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
pand            0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
pcscd           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
portmap         0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
psacct          0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
rawdevices      0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
rdisc           0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
readahead_early 0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
readahead_later 0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:启用  6:关闭
restorecond     0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
rhnsd           0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
rpcgssd         0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
rpcidmapd       0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
rpcsvcgssd      0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
saslauthd       0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
sendmail        0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
setroubleshoot  0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
smartd          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
sshd            0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
syslog          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
sysstat         0:关闭  1:关闭  2:启用  3:启用  4:关闭  5:启用  6:关闭
vncserver       0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
vsftpd          0:关闭  1:关闭  2:关闭  3:启用  4:关闭  5:启用  6:关闭
wdaemon         0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
winbind         0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
wpa_supplicant  0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
xfs             0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
xinetd          0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
ypbind          0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
yum-updatesd    0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

基于 xinetd 的服务:
        chargen-dgram:  关闭
        chargen-stream: 关闭
        cvs:            关闭
        daytime-dgram:  关闭
        daytime-stream: 关闭
        discard-dgram:  关闭
        discard-stream: 关闭
        echo-dgram:     关闭
        echo-stream:    关闭
        eklogin:        关闭
        ekrb5-telnet:   关闭
        gssftp:         启用
        klogin:         关闭
        krb5-telnet:    关闭
        kshell:         关闭
        rmcp:           关闭
        rsync:          关闭
        tcpmux-server:  关闭
        tftp:           关闭
        time-dgram:     关闭
        time-stream:    关闭
[root@jfht ~]#

 

示例三

[root@jfht ~]# chkconfig --list xinetd 
xinetd          0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭
[root@jfht ~]# chkconfig xinetd off 
[root@jfht ~]# chkconfig --list xinetd 
xinetd          0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭
[root@jfht ~]# chkconfig xinetd on 
[root@jfht ~]# chkconfig --list xinetd 
xinetd          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
[root@jfht ~]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值