更换 cnetos 软件源

本文最后更新于 2024年4月26日 凌晨

linux-centos-mirror

实践环境: CentOS Linux release 7.8.2003 (Core)

1. 备份软件源目录

1
2
3

sudo cp -r /etc/yum.repos.d/ /etc/yum.repos.d.bk

2. 修改软件源列表

运行一下命令,修改软件源

  • CentOS 7
1
2
3
4
5
6
7
8
9

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \

         -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \

         -i.bak \

         /etc/yum.repos.d/CentOS-*.repo

  • CentOS 8
1
2
3
4
5
6
7
8
9

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \

         -e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos|g' \

         -i.bak \

         /etc/yum.repos.d/CentOS-*.repo

更新软件包缓存

1
2
3

sudo yum makecache

参考

  1. centos | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror: https://mirrors.tuna.tsinghua.edu.cn/help/centos/
  2. CentOS 源使用帮助 — USTC Mirror Help 文档: https://mirrors.ustc.edu.cn/help/centos.html

感谢

感谢 清华大学镜像站,南京大学镜像站提供镜像服务


更换 cnetos 软件源
https://blog.cc01cc.cn/2023/10/08/linux-centos-mirror/
作者
零一/cc01cc(zeo)
发布于
2023年10月8日
更新于
2024年4月26日
许可协议