Centos 7安装后的几点优化
Centos7相对之前的5和6改动比较大,所以单独新开一章单独来表
修改主机名
hostnamectl set-hostname moneypy
关闭selinux临时关闭
setenforce 0
查看当前状态
getenforce
永久关闭
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
1.安全配置修改ssh端口
sed -i 's/# Port 22/Port 20002/g' /etc/ssh/ssh_config sed -i 's/#Port 22/Port 20002/g' /etc/ssh/sshd_config systemctl restart sshd systemctl status sshd firewall-cmd --zone=public --add-port=20002/tcp --permanent firewall-cmd --reload
修改默认端口22为20002,添加20002到防火前例外
2.修改软件源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup cd /etc/yum.repos.d/ rm -rf * wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo yum clean all yum makecache