Linux chkconfig --查询/修改系统服务的运行级别

来源:互联网 发布:coc法师塔升级数据 编辑:程序博客网 时间:2024/05/01 23:59

用途说明

chkconfig命令用于更新和查询系统Linux系统服务的运行级别信息(updatesand queries runlevel information for system services)。chkconfig提供一个简单的命令行工具,它可以用来维护/etc/rc[0-6].d目录里面一些符号链接chkconfig provides a simple command-line tool formaintaining the /etc/rc[0-6].d directory hierarchy by relieving systemadministrators of the task of directly manipulating the numerous symboliclinks  in  those  directories.)。chkconfig命令有五种不同的功能(chkconfighas five distinct functions:添加新的服务(adding new services for management,删除服务(removingservices  from  management,列出系统服务的当前启动信息(listing the current startup information forservices,更改服务的启动信息(changing the startup information for services,以及检查特定服务的启动状态(andchecking the startup state of a particular service.)。

每个能用chkconfig管理的系统服务脚本需要两个或更多特殊注释行(Eachservice which should be manageable by chkconfig needs two or morecommented  lines  added  to  its  init.d script第一行是该系统服务在哪些运行级别启动、启动优先级和停止优先级(The  first line tells chkconfig what runlevelsthe service should be started in by default, as well as the start and stoppriority 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 theservice, 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 priorityshould 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 theline 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_early0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

readahead_later0:关闭  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 ~]#

 

0 0