Administrator
发布于 2025-02-10 / 9 阅读
0

centos7添加阿里云yum源

备份当前yum源

[root@localhost ~]# sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载阿里云Centos7源配置文件

方法1

[root@localhost ~]# sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

方法2

如果操作系统默认安装的是最小化安装可能没有wget命令,下载centos7源就需要换一种方法

先把CentOS-Base.repo文件清空

echo > /etc/yum.repos.d/CentOS-Base.repo

使用curl命令把返回的数据保存到CentOS-Base.repo文件中

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

清除缓存并生成新的缓存

[root@localhost ~]# yum clean all

[root@localhost ~]# yum makecache

更新包

[root@localhost ~]# yum -y update