centos7 系统初始化配置
1、设置ip地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192 PROXY_METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "static" DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" NAME= "ens192" DEVICE= "ens192" ONBOOT= "yes" IPADDR= "192.168.82.232" PREFIX= "24" GATEWAY= "192.168.82.1" DNS1= "114.114.114.114" [root@localhost ~]# |
2、修改主机名
1 | hostnamectl set -hostname postmail |
3、更改yum源、update
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #备份现有源配置 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup #rpm安装wget rpm -ivh http: //mirrors.163.com/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm #下载并替代本地源 yum install -y wget wget -O /etc/yum.repos.d/CentOS-Base.repo http: //mirrors.aliyun.com/repo/Centos-7.repo #修改Centos-7.repo文件将所有$releasever替换为7 yum install -y vim vim /etc/yum.repos.d/CentOS-Base.repo #输入替换命令 %s/$releasever/7/g wget -O /etc/yum.repos.d/epel.repo http: //mirrors.aliyun.com/repo/epel-7.repo yum clean all yum makecache #添加epel源 yum install -y epel-release #update yum -y update |
4、关闭防火墙
1 2 3 4 5 6 | #查看防火墙状态 systemctl status firewalld #关闭防火墙 systemctl stop firewalld #关闭开机启动防火墙 systemctl disable firewalld |
5、关闭selinux
1 2 3 4 5 6 7 8 9 | #查看selinux状态 getenforce #临时关闭 setenforce 0 #永久关闭 #SELINUX=enforcing 改为 SELINUX=disabled vim /etc/sysconfig/selinux |
6、调整系统时区
1 2 3 4 | timedatectl set -timezone Asia/Shanghai timedatectl set -local-rtc 0 systemctl restart rsyslog systemctl restart crond |
7、关闭系统不需要的服务
1 2 | ss -tnl systemctl stop postfix && systemctl disable postfix |
8、安装net-tools
1 | yum install -y net-tools |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)