C/C++教程

CentOS7更换国内yum源

本文主要是介绍CentOS7更换国内yum源,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.备份原Base源

cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
# ====== 更换清华源请使用 ======
cp CentOS-Base.repo CentOS-Base.repo.bak

2.更换国内源

下面的操作任选一个即可

阿里镜像源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

清华镜像源

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

3.更新软件包缓存

yum makecache

参考:
阿里源CentOS 镜像:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b113id1k6
清华源CentOS 镜像使用帮助:https://mirrors.tuna.tsinghua.edu.cn/help/centos/

这篇关于CentOS7更换国内yum源的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!