【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

 

转载于:https://www.cnblogs.com/william126/p/8735247.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值