【Linux优化】Linux安装之后的优化
yum source config
mv /etc/yum.repos.d/CentOS-Base.repo{,.bkp}
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum makecache
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
update
ll /etc/pki/rpm-gpg/
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum update -y
Close SELinux
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
getenforce
#Permissive
Close services
for oldboy in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $oldboy off;done
chkconfig --list|grep 3:on
for oldboy in crond network rsyslog sshd sysstat;do chkconfig --level 3 $oldboy on;done
chkconfig --list|grep 3:on
for oldboy in `chkconfig --list|grep "3:on"|awk '{print $1}'|grep -vE "crond|network|sshd|rsyslog|sysstat"`;do
chkconfig $oldboy off;done
chkconfig --list|grep 3:on|grep -vE "crond|sshd|network|rsyslog|sysstat"|awk '{print "chkconfig " $1 " off"}'|bash
Close firewall
/etc/init.d/iptables stop
chkconfig iptables off
Charset
cp /etc/sysconfig/i18n{,.bkp}
echo 'LANG="zh_CN.UTF-8"' >/etc/sysconfig/i18n
sync time
/usr/sbin/ntpdate time.nist.gov
echo '#Time sync by william at 2018-04-05' >>/var/spool/cron/root
echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov > /dev/null >&1' >> /var/spool/cron/root
HIstory Set
export TMOUT=100
export HISTSIZE=100
export HISTFILESIZE=5
echo 'export TMOUT=100' >>/etc/profile
echo 'export HISTSIZE=100' >>/etc/profile
echo 'export HISTFILESIZE=5'>>/etc/profile
source /etc/profile
echo "unset MAILCHECK" >>/etc/profile
source /etc/profile
cat /dev/null > /var/spool/mail/root
ulimit -n
#65535
echo '* - nofile 65535' >>/etc/security/limits.conf
Sec
chattr +i /etc/passwd
chattr +i /etc/inittab
chattr +i /etc/group
chattr +i /etc/shadow
chattr +i /etc/gshadow
lsattr /etc/passwd
find /var/spool/postfix/maildrop/ -type f|xargs rm -f
>/etc/issue
>/etc/issue.net
grup
/sbin/grub-md5-crypt
password --md5 $1$hmiFo/$GgaI7QZUFJMeMTvgUCUfp/
core
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl =15
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 32768
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_wmem = 8192 131072 16777216
net.ipv4.tcp_rmem = 32768 131072 16777216
net.ipv4.tcp_mem = 786432 1048576 1572864
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_conntrack_max = 65536
net.ipv4.netfilter.ip_conntrack_max=65536
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=180
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.ip_conntrack_max = 25000000
net.ipv4.netfilter.ip_conntrack_max = 25000000
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60
net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120
posted on 2018-04-07 22:21 William126 阅读(162) 评论(0) 编辑 收藏 举报