【命令名称】 chkconfig
【使用权限】 所有人
【命令功能】 管理系统服务默认开机启动与否
【命令语法】 chkconfig --list [服务名称]
chkconfig --add|del [服务名称]
chkconfig [--level [0123456]] [服务名称] [on|off]
【常用参数】
--list 仅将目前的各项服务状态栏显示出来
--level 设置某个服务在LEVEL下启动或者关闭
--add|del 增加一个服务给chkconfig管理|删除从chkconfig管理的一个服务
【命令实例】
1 显示出所有文件的服务状态
[cxc@cxcserver test3]$ sudo chkconfig --list |head -6
[sudo] password for cxc:
NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off
acpid 0:off 1:off 2:on 3:off 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:off 4:on 5:on 6:off
apmd 0:off 1:off 2:on 3:off 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:off 4:on 5:on 6:off
auditd 0:off 1:off 2:on 3:off 4:on 5:on 6:off
[cxc@cxcserver test3]$
2 让mysql这个服务在run-level 35 时关闭
[cxc@cxcserver test3]$ chkconfig --list |grep httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[cxc@cxcserver test3]$ sudo chkconfig --level 35 httpd off
[cxc@cxcserver test3]$ chkconfig --list |grep httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[cxc@cxcserver test3]$
3 把不必要的服务关闭,只开启需要的服务,脚本(参考老男孩老师)
for cxc in `chkconfig --list|grep 3on|awk '{print $1}'`;do chkconfig --level 3 $oldboy off;done
for cxc in crond network syslog sshd;do chkconfig --level 3 $oldboy on;done
转载于:https://blog.51cto.com/chinalscxc/1131517