MENU

一行代码 更换Centos更新源

August 26, 2024 • 已被 237 位童鞋围观过 • 系统运维

CentOS 7 是基于 RHEL 7 的社区版,官方对其的全面支持在 2024 年 6 月 30 日已经结束,这意味着官方不再提供常规的更新和安全补丁。导致的问题就是 安装完系统不能直接使用官方的yum update 命令进行系统更新了,但是你可以使用国内的其它源进行这个操作

更换阿里云源

sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

更换网易云源

sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak && sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.163.com/.help/CentOS7-Base-163.repo

操作完就可以直接使用 yum update更新系统了,我更倾向于使用aliyun的源,速度好像更快一些。

新增一个一键更换源的脚本,推荐 腾讯(海外主机推荐) 阿里云 网易。 GCP在镜像中搜索centos 选择hpc-centos7 内置的是cloudflare的更新源 速度很快。

国内使用

bash <(curl -sSL https://linuxmirrors.cn/main.sh)

教育网

bash <(curl -sSL https://linuxmirrors.cn/main.sh) --edu

github 地址

bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh)

gitee 地址

bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)

海外使用

bash <(curl -sSL https://linuxmirrors.cn/main.sh) --abroad

github 地址

bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/ChangeMirrors.sh) --abroad

gitee 地址

bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --abroad
Last Modified: September 6, 2024