老葵花哥哥又开课了 接下来是你们的齐天大圣孙悟空给你们带来的详细版Linux系统开机启动优化四种命令 第一种方法是很正常的 第二种有点难理解 第三种来自我的一个奇思妙想
本文档秉承 不要钱也不要臀部的高尚思想共享理念
各位多给我提意见 大圣需要你们支持
##第一个里程碑-想要的结果 (知道自己要的是什么)
chkconfig 服务名字 off
这种形式
chkconfig abrt-ccpp off
chkconfig abrtd off
chkconfig acpid off
##第二个里程碑-先排除crondrsyslog network sshd sysstat
(你可以理解为我们要处理他们之外的语句)
[root@oldboyedu-39-nb ~]# chkconfig |egrep"sshd|crond|rsyslog|network|sysstat"
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off
[root@oldboyedu-39-nb ~]# chkconfig |egrep -v"sshd|crond|rsyslog|network|sysstat"
abrt-ccpp 0:off 1:off 2:off 3:on 4:off 5:on 6:off
abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
quota_nld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rdma 0:off 1:on 2:on 3:on 4:on 5:on 6:off
restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rngd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
smartd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
svnserve 0:off 1:off 2:off 3:off 4:off 5:off 6:off
udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off
##第三个里程碑-取出服务名字 (你可以尝试不要括号里的^符号思想无界限)
[root@oldboyedu-39-nb ~]# chkconfig |egrep -v"sshd|crond|rsyslog|network|sysstat"|sed -r 's#(^.*)0.*#1#g'
abrt-ccpp
abrtd
acpid
atd
auditd
blk-availability
cpuspeed
haldaemon
ip6tables
iptables
irqbalance
restorecond
rngd
saslauthd
smartd
svnserve
udev-post
##第四个里程碑-拼接出chkconfig 服务名字 off 样子 (抱歉 排版出来特别差劲)
[root@oldboyedu-39-nb ~]# chkconfig |egrep -v"sshd|crond|rsyslog|network|sysstat"|sed -r 's#(^.*)0.*#chkconfig 1off#g'
chkconfig abrt-ccpp off
chkconfig abrtd off
chkconfig acpid off
chkconfig atd off
chkconfig auditd off
chkconfig blk-availability off
chkconfig cpuspeed off
chkconfig rdma off
chkconfig restorecond off
chkconfig rngd off
chkconfig saslauthd off
chkconfig smartd off
chkconfig svnserve off
chkconfig udev-post off
##第五个里程碑-有了命令的形式样子,有人来运行 执行
[root@oldboyedu-39-nb ~]# echo ls
ls
[root@oldboyedu-39-nb ~]# echo ls|bash
access-2017-05-20.log anaconda-ks.cfg hosts num.txt person.txt wang.txt
access-2017-05-21.log anaconda-screenshots install.log oldboy-2017-08-03.log person.txt.ori
access-2017-05-22.log a.txt install.log.syslog oldboy.txt-hard q.txt
access-2017-08-03.log b.txt lista.txt –p services
a.log data listb.txt passwd.txt test.txt
[root@oldboyedu-39-nb ~]# echo pwd|bash
/root
[root@oldboyedu-39-nb ~]# chkconfig |egrep -v"sshd|crond|rsyslog|network|sysstat"|sed -r 's#(^.*)0.*#chkconfig 1off#g'|bash
[root@oldboyedu-39-nb ~]# chkconfig |grep 3:on
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off
###排除的方法
chkconfig |sed -r '/sshd|rsyslog|crond|network|sysstat/d'
chkconfig |sed -rn '/sshd|rsyslog|crond|network|sysstat/!p'
###拼接
chkconfig |sed -rn '/sshd|rsyslog|crond|network|sysstat/!p'|sed -r's#(.*)0.*#1#gp'
chkconfig |sed -rn '/sshd|rsyslog|crond|network|sysstat/!p'
对于包含sshd或rsyslog或crond或 network或sysstat的行 不处理 不进行替换 sg
// ! s###g
其他方法请查看
http://13039592.blog.51cto.com/13029592/1956926