系统优化脚本

#!/bin/shuser=alan#shutdown iptableschkconfig iptables off  && /etc/init.d/iptables stop #shutdown selinuxsed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config cat /etc/selinux/config setenforce 0 getenforce &&#create a user useradd $user echo "123456"|passwd --stdin $user#Modify the yum sourcecd /etc/yum.repos.d /bin/mv CentOS-Base.repo CentOS-Base.repo.bak wget http://mirrors.163.com/.help/CentOS6-Base-163.repo /bin/mv CentOS6-Base-163.repo CentOS-Base.repo &&#install lrzsz sysstatyum -y install lrzsz sysstat  >/dev/null 2>&1yum -y groupinstall ±x software development >/dev/null 2>&1 °&& #Close unnecessary servicesfor n in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $n off;done for m in crond network rsyslog sshd;do chkconfig --level 3 $m on;done#Set the SSH servicecp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak cat>>/etc/ssh/sshd_config<
>/etc/sudoers #Set LANGecho 'LANG="en_US.UTS-8"'>/etc/sysconfig/i18n  #Time synchronization/usr/sbin/ntpdate time.windows.com echo "*/5 * * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1 ">>/var/spool/cron/root  #Set limitsecho °* - nofile 65535±>>/etc/security/limits.conf #seo sysctlcat>>/etc/sysctl.conf<
/dev/null 2>&1sysctl -p

优化结果检查脚本

#!/bin/shuser=alan#check iptables/etc/init.d/iptables status #check selinuxgetenforce##check userid $user#check yumls -l /etc/yum.repos.d#check apprpm -qa lrzsz sysstat #check serviceschkconfig --list|grep 3:on#check sshtail -5 /etc/ssh/sshd_config#check sudoertail -1 /etc/sudoers#check ntpdatecrontab -l#check limitstail -1 /etc/security/limits.conf