`

我使用过的Linux命令之chkconfig - 查询/修改系统服务的运行级别

阅读更多

我使用过的Linux命令之chkconfig - 查询/修改系统服务的运行级别

本文链接: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:关闭
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 ~]#

 

问题思考

相关资料

【1】Bash @ Linux 我使用过的Linux命令之service - 系统服务管理
http://codingstandards.iteye.com/blog/985455

【2】飞诺网 linux中chkconfig命令详解
http://dev.firnow.com/course/6_system/linux/Linuxjs/20081020/150848.html
【3】youyu_buzai的专栏 chkconfig命令
http://blog.csdn.net/youyu_buzai/archive/2009/03/04/3956845.aspx
【4】ChinaUnix.net [精华] 用chkconfig 管理 Init 脚本[转贴]
http://www.chinaunix.net/jh/4/203105.html
【5】百度百科 chkconfig
http://baike.baidu.com/view/2098380.html?fromTaglist

 

 

返回 我使用过的Linux命令系列总目录

 

1
0
分享到:
评论

相关推荐

    mysql-test-5.7.22-linux-glibc2.12-x86_64.tar.gz

    1、在官网上下载mysql-5.7.22-linux,我下载的是mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz,https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz,centos7/64位。...

    chkconfig-1.19.1-1.el8.x86_64.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    chkconfig-1.19.1-1.el8.aarch64.rpm

    离线安装包,亲测可用

    chkconfig-1.7.4-1.el7.x86_64.rpm

    离线安装包,亲测可用

    chkconfig-1.3.30c.tar.gz

    chkconfig-1.3.30c.tar.gz 解压后: ./configure make make install

    Linux rsh命令用法详解

    Linux rsh命令 Linux rsh命令用于远端登入的Shell。 rsh(remote shell)提供用户环境,也就是Shell,以便指令能够在指定的远端主机上执行。 语法rsh [-dn][-l ][主机名称或IP地址][执行指令] 参数说明: -d 使用...

    chkconfig-1.3.49.3-2.el6.i686.rpm

    chkconfig-1.3.49.3-2.el6.i686.rpm是centos工具包。

    Linux下chkconfig命令详解.docx

    Linux下chkconfig命令详解.docx

    Linux chkconfig命令用法详解

    Linux chkconfig命令用于检查,设置系统的各种服务。 这是Red Hat公司遵循GPL规则所开发的程序,它可查询操作系统在每一个执行等级中会执行哪些系统服务,其中包括各类常驻服务。 语法 chkconfig [--add][--del][--...

    操作系统安全:关闭多余服务.docx

    //35指的是运行级别 查看所有服务的启动状态:chkconfig --list 查看某个服务的启动状态:chkconfig --list sshd 各系统服务相关描述 不要关闭以下服务(除非你有充足的理由): acpid, haldaemon, messagebus, ...

    Linux下的chkconfig命令详解

    Linux下的chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。 使用语法 chkconfig [–add][–del][–list][系统...

    NFS服务器客户机配置

    #chkconfig --list portmap 查看服务器运行级别3,5是否开启。 #chkconfig --list nfs 查看服务器运行级别3,5是否开启。 #chkconfig --level 35 nfs on 开启3,5运行级别。 #chkconfig --level 35 iptables off ...

    LNMP架构安装

    chkconfig --add mysqld ln -s /usr/local/mysql/bin/* /usr/local/bin/ ln -s /usr/local/mysql/lib/mysql/* /usr/lib ln -s /usr/local/mysql/include/mysql/* /usr/include/ useradd -M -u 27 -s /sbin/nologin ...

    chkconfig-1.13-2.el8.aarch64.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    操作系统安全:chkconfig.docx

    chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。 使用语法: chkconfig [--add][--del][--list][系统服务] 或 ...

    Linux启动运行级别&chkconfig&crontab.pdf

    Linux启动运行级别&chkconfig&crontab.pdf

    使用 chkconfig 和 systemctl 命令启用或禁用 Linux 服务的方法

    在 Linux 中,无论何时当你安装任何带有服务和守护进程的包,系统默认会把这些服务的初始化及 systemd 脚本添加进去...下面小编给大家带来了使用 chkconfig 和 systemctl 命令启用或禁用 Linux 服务的方法,一起看看吧

    chkconfig_11.0-79.1-2_all.deb

    在ubuntu上默认是不支持chkconfig命令的,但可以自己安装,安装包已经上传,方法:在存放目录执行:dpkg -i chkconfig_11.0-79.1-2_all.deb

    Linux 添加系统服务、设置开机启动、设置启动顺序、chkconfig.docx

    文档是我自己亲自整理的文档,详细介绍了 chkconfig 命令,使用该命令再进行配置Linux的服务和启动服务

    linux命令详解之chkconfig命令使用方法

    使用语法:chkconfig[–add][–del][–list][系统服务] 或chkconfig[–level &lt; 等级代号&gt;][系统服务][on/off/reset] chkconfig在没有参数运行时,显示用法。如果加上服务名,那么就检查这个服务是否在当前运行级...

Global site tag (gtag.js) - Google Analytics