第一步、删除不必要的自带软件包
yumremoveDeployment_Guide-en-USfingercups-libscupsypbind
yumremovebluez-libsdesktop-file-utilsppprp-pppoewireless-toolsirda-utils
yumremovesendmail*samba*talk-serverfinger-serverbind*xinetd
yumremovenfs-utilsnfs-utils-librdatefetchmailejectkshmkbootdiskmtools
yumremovesyslinuxtcshstartup-notificationtalkapmdrmtdumpsetserialportmapyp-tools
yumgroupremove"MailServer""GamesandEntertainment""XWindowSystem""XSoftwareDevelopment"
yumgroupremove"DevelopmentLibraries""DialupNetworkingSupport"
yumgroupremove"GamesandEntertainment""SoundandVideo""Graphics""Editors"
yumgroupremove"Text-basedInternet""GNOMEDesktopEnvironment""GNOMESoftwareDevelopment"
第二步、升级centos系统
yumupdate#更新系统
yumcleanall#清理全部缓存文件
第三步、禁用seLinux
sestatus#先执行看seLinux状态,如果不是disabled,就需要执行下面步骤,否则不要执行
vi/etc/selinux/config
SELINUX=disabled#禁用SeLinux
SELINUX=enforcing#使用SeLinux
第四步、禁止IPV6(执行后需要reboot重启)
vi/etc/modprobe.conf#打开文件,把下面两行加到最后
aliasnet-pf-10off
aliasipv6off
第五步、初始化防火墙
touch/etc/sysconfig/iptables
iptables-F
iptables-X
iptables-Z
serviceiptablessave
serviceiptablesrestart
第六步、禁止无用服务
#!/bin/bash
serviceacpidoff
serviceatdstop
serviceauditdstop
serviceavahi-daemonstop
serviceavahi-dnsconfdstop
servicebluetoothstop
serviceconmanstop
servicecpuspeedstop
servicecupsstop
servicednsmasqstop
servicedundstop
servicefirstbootstop
servicehiddstop
servicehttpdstop
serviceibmasmstop
serviceip6tablesstop
serviceirdastop
servicekdumpstop
servicelm_sensorsstop
servicemcstransstop
servicemessagebusstop
servicemicrocode_ctlstop
servicenetconsolestop
servicenetfsstop
servicenetplugdstop
servicenfsstop
servicenfslockstop
servicenscdstop
servicentpdstop
serviceoddjobdstop
servicepandstop
servicepcscdstop
serviceportmapstop
servicepsacctstop
servicerdiscstop
servicerestorecondstop
servicerpcgssdstop
servicerpcidmapdstop
servicerpcsvcgssdstop
servicesaslauthdstop
servicesendmailstop
servicesetroubleshootstop
servicesmbstop
servicevncserverstop
servicewinbindstop
servicewpa_supplicantstop
servicexfsstop
serviceypbindstop
serviceyum-updatesdstop
chkconfigacpidoff
chkconfigatdoff
chkconfigauditdoff
chkconfigavahi-daemonoff
chkconfigavahi-dnsconfdoff
chkconfigbluetoothoff
chkconfigconmanoff
chkconfigcpuspeedoff
chkconfigcupsoff
chkconfigdnsmasqoff
chkconfigdundoff
chkconfigfirstbootoff
chkconfighiddoff
chkconfighttpdoff
chkconfigibmasmoff
chkconfigip6tablesoff
chkconfigirdaoff
chkconfigkdumpoff
chkconfiglm_sensorsoff
chkconfigmcstransoff
chkconfigmessagebusoff
chkconfigmicrocode_ctloff
chkconfignetconsoleoff
chkconfignetfsoff
chkconfignetplugdoff
chkconfignfsoff
chkconfignfslockoff
chkconfignscdoff
chkconfigntpdoff
chkconfigoddjobdoff
chkconfigpandoff
chkconfigpcscdoff
chkconfigportmapoff
chkconfigpsacctoff
chkconfigrdiscoff
chkconfigrestorecondoff
chkconfigrpcgssdoff
chkconfigrpcidmapdoff
chkconfigrpcsvcgssdoff
chkconfigsaslauthdoff
chkconfigsendmailoff
chkconfigsetroubleshootoff
chkconfigsmboff
chkconfigvncserveroff
chkconfigwinbindoff
chkconfigwpa_supplicantoff
chkconfigxfsoff
chkconfigypbindoff
chkconfigyum-updatesdoff
这样通过上述6步骤,就可以完成对centos精简和优化。