一条命令替换成 清华源:
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 镜像使用帮助
该文件夹只提供 CentOS 7 与 8,架构仅为 x86_64 ,如果需要较早版本的 CentOS,请参考 centos-vault 的帮助,若需要其他架构,请参考 centos-altarch 的帮助。
建议先备份 /etc/yum.repos.d/ 内的文件(CentOS 7 及之前为 CentOS-Base.repo,CentOS 8
为CentOS-Linux-*.repo)然后编辑 /etc/yum.repos.d/ 中的相应文件,在 mirrorlist= 开头行前面加 # 注释掉;并将 baseurl=
开头行取消注释(如果被注释的话),把该行内的域名(例如mirror.centos.org)替换为
mirrors.tuna.tsinghua.edu.cn。以上步骤可以被下方的命令一步完成
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 注意其中的*通配符,如果只需要替换一些文件中的源,请自行增删。注意,如果需要启用其中一些 repo,需要将其中的 enabled=0 改为 enabled=1。
最后,更新软件包缓存
sudo yum makecache
一键切换:CentOS 使用清华源加速
本文介绍了如何方便地将CentOS的yum源替换为清华大学的镜像源,以提高软件包下载速度。只需运行一条命令,即可修改/etc/yum.repos.d/中的CentOS-*.repo文件,将mirrorlist行注释并替换baseurl为mirrors.tuna.tsinghua.edu.cn。别忘了先备份原有文件,并根据需要启用repo,最后执行yum makecache更新缓存。
1163

被折叠的 条评论
为什么被折叠?



