YUM
安装管理工具:
sudo yum clean allsudo yum makecachesudo yum install yum-utils
国内源
阿里云:
# 备份原配置$ sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup# CentOS 7$ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo# CentOS 8$ sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo# 重新生成缓存$ sudo yum makecache
中科大:
# CentOS 6/7$ sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \-e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \-i.bak \/etc/yum.repos.d/CentOS-Base.repo# CentOS 8$ sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \-e 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/centos|g' \-i.bak \/etc/yum.repos.d/CentOS-Base.repo \/etc/yum.repos.d/CentOS-Extras.repo \/etc/yum.repos.d/CentOS-AppStream.repo# 重新生成缓存$ sudo yum makecache
仓库管理
查看所有:
$ sudo yum repolist allLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfilerepo id repo name statusC7.0.1406-base/x86_64 CentOS-7.0.1406 - Base disabled省略...base/7/x86_64 CentOS-7 - Base enabled: 10,070base-debuginfo/x86_64 CentOS-7 - Debuginfo disabledbase-source/7 CentOS-7 - Base Sources disabled省略...
启用/禁用:
# 禁用sudo yum-config-manager --disable [仓库名]# 启用sudo yum-config-manager --enable [仓库名]
EPEL
安装
sudo yum install epel-releasesudo makecache
国内源
# 中科大sudo sed -e 's|^metalink=|#metalink=|g' \-e 's|^#baseurl=https\?://download.fedoraproject.org/pub/epel/|baseurl=https://mirrors.ustc.edu.cn/epel/|g' \-i.bak \/etc/yum.repos.d/epel.repo
