CentOS 7
# 备份原有源文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.back
# 下载源文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
# 生成缓存
yum makecache
yum install -y epel-release
cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.back
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
yum makecache
CentOS 7 ARM
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/altarch/|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/|g' \
-e 's|^#baseurl=http://mirror.centos.org/$contentdir/|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-altarch/|g' \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo
# 生成缓存
yum makecache
yum install -y epel-release
cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.back
sed -e 's!^metalink=!#metalink=!g' \
-e 's!^#baseurl=!baseurl=!g' \
-e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
-e 's!//download\.example/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
-e 's!http://mirrors!https://mirrors!g' \
-i /etc/yum.repos.d/epel*.repo
yum update
CentOS 8
rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
Ubuntu 20
# 备份源文件
cp /etc/apt/sources.list /etc/apt/sources.list.back
wget -O /etc/apt/sources.list http://mirrors.cloud.tencent.com/repo/ubuntu20_sources.list
# 更新源信息
apt update