前言

刚装好Linux系统一脸懵?黑白终端劝退?网络无法连接?别慌!这份保姆级初始化清单,专治各种“安装后不适症”,让你的Linux秒变顺手生产力工具!

1. 安全初始化:关防火墙/SELinux(学习环境适用)

# 关闭防火墙+清空规则
systemctl stop firewalld && systemctl disable firewalld
iptables -F

# 临时关闭
SELinuxsetenforce 0    # 临时生效
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config  # 永久关闭🚀 加速秘籍:换国内源+时间同步

2. CentOS 7 网络配置步骤(手动修改配置文件)

确定网卡名称

ip link | grep "state UP"  # 找到类似 "ens33" 的网卡名

配置文件

vi /etc/sysconfig/network-scripts/ifcfg-你的网卡名  # 如 ifcfg-ens33

修改以下核心参数

BOOTPROTO=static        # 值修改为static静态
IPONBOOT=yes            # 开机启动
IPADDR=192.168.1.100    # 自定义IP地址(根据你的网络修改)
PREFIX=24               # 子网掩码
GATEWAY=192.168.1.1     # 网关地址(通常路由器IP)
DNS1=8.8.8.8            # 首选DNS
DNS2=114.114.114.114    # 备用DNS

<span leaf=""><span textstyle="">温馨提示:</span></span>所有值不加引号、IP参数需符合你的网络环境!

保存退出

按 Esc → 输入 :wq → 回车

重启网络服务

systemctl restart network

验证配置

ip addr show          # 查看IP是否生效
ping www.baidu.com    # 测试网络连通性

加速秘籍:换国内源,切换阿里云软件源(解决yum卡顿)

1、运行以下命令备份原软件源。    
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、运行以下任一命令添加CentOS 7软件源。    
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

#epel源
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
最后修改:2025 年 08 月 09 日
如果觉得我的文章对你有用,请随意赞赏