1.查看系统所有的服务
#chkconfig --list |
cat -n
 
2.先关闭系统所有的服务
(说明:由于基于xinetd的服务都是有xinetd管理,所以这里只关闭xinetd以上行的服务,head
-112
根据实际情况来指定其数值)
#for s in `chkconfig
--list | head -112 | awk '{print $1}'` ;do chkconfig $s off ; done
或者
#for s in `chkconfig --list | awk 'NR==1,NR==112{print $1}'` ;do
chkconfig $s off ; done
3.开启系统必需启动的服务(根据自己的实际情况而定)
#for s in crond
iptables irqbalance messagebus network syslog sshd  ;do chkconfig $s on ; done
4.查看开启的服务
#chkconfig --list | awk  '/5:启用/{print NR ,$0 }'