yzwj2004 发表于 2019-4-17 15:43:15

centos7简易优化

centos7系统初始优化

yum install wget net-toolslrzsz-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 "web01ALL=(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
页: [1]
查看完整版本: centos7简易优化