1、说明
chkconfig [--add][--del][--list][系统服务]
chkconfig [--level <等级代号>][系统服务][on/off/reset]
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.
2、option
① add 增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据。
② del 删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据。
③ level<等级代号> 指定读系统服务要在哪一个执行等级中开启或关毕。
3、其他
1)运行级别就是操作系统当前正在运行的功能级别。这个级别从0到6,具有不同的功能。这些级别在/etc/inittab文件里指定。这个文件是init程序寻找的主要文件,最先运行的服务是那些放在/etc/rc.d目录下的文件。
2)运行级别
3:有网络支持的多用户模式
5:有网络支持有X-Window支持的多用户模式
4、示例
chkconfig --list 列出所有的系统服务
chkconfig --add httpd 增加httpd服务
chkconfig --del httpd 删除httpd服务
chkconfig --level 2345 httpd on 把httpd在运行级别为2、3、4、5的情况下都是on(开启)的状态。
chkconfig --level 5 sshd on
5、执行类似 chkconfig rsync on 命令时会立即启动服务。但是,chkconfig --level 345 nscd off 不会自动停止 nscd 服务,而需要等待系统重启后才生效。希望马上启用或停止某个服务,可以使用service<service><action>命令;其中<service>为服务名称,<action>为操作动作,可以为start(启动)、stop(停止)、restart(重启)。
6、chkconfig命令如何增加一个服务:
① 服务脚本必须存放在/etc/ini.d/目录下
② chkconfig --add servicename //在chkconfig服务列表中增加此服务,该服务会在/etc/rc.d/rcN.d中被赋予K/S入口
③ chkconfig --level 35 mysqld on
修改服务的默认启动等级。
参考
【1】 http://linux.die.net/man/8/chkconfig
【2】 http://www.cnblogs.com/Vegaslee/archive/2011/01/27/1946066.html
【3】 http://lugir.com/story/185.html
【4】 http://os.51cto.com/art/201006/207648.htm
【5】 /etc/inittab的说明
http://hi.baidu.com/lianxi1999/blog/item/75c9eb0f870549eeaa64570c.html