centos7简易优化

centos7系统初始优化

yum install wget net-tools  lrzsz-y

更改yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

关闭selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
getenforce

关闭防火墙

/etc/init.d/iptables stop
/etc/init.d/iptables stop
chkconfig iptables off
systemctl stop firewalld
systemctl disable firewalld

提权非root用户管理

useradd web01
echo 123456|passwd --stdin web01
\cp /etc/sudoers /etc/sudoers.ori
echo "web01  ALL=(ALL) NOPASSWD: ALL " >>/etc/sudoers
tail -1 /etc/sudoers
visudo -c

时间同步

echo '*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1' >>/var/spool/cron/root
crontab -l

操作历史记录保留行减少

#echo 'export TMOUT=300' >>/etc/profile
#echo 'export HISTSIZE=5' >>/etc/profile
#echo 'export HISTFILESIZE=5' >>/etc/profile
#tail -3 /etc/profile
#. /etc/profile

文件描述符增加

echo '*               -       nofile          65535 ' >>/etc/security/limits.conf 
tail -1 /etc/security/limits.conf 

内核基础优化

cat >>/etc/sysctl.conf<

补充几个工具

yum install nmap tree dos2unix nc -y

ssh连接优化

#sed -i '13aPort 52013' /etc/ssh/sshd_config
sed -i 's#GSSAPIAuthentication yes#GSSAPIAuthentication no#g' /etc/ssh/sshd_config
sed -i '123aUseDNS yes' /etc/ssh/sshd_config

service sshd reload

转载于:https://blog.51cto.com/linux1991/2373878

你可能感兴趣的:(centos7简易优化)