CentOS7修改默认yum源为阿里云yum源

桃扇骨 2022-01-26 15:19 443阅读 0赞

1、先确保可以运行wget命令,若不可以运行wget命令,先用默认yum源安装wget工具:yum install -y wget

2、备份系统默认yum源:

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

3、下载阿里云yum源,这里下载的是centos7:

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

4、生成缓存:

  1. [root@localhost ~]# yum clean all
  2. [root@localhost ~]# yum makecache

5、完成修改yum源

注意事项:若新手刚完成centos的安装可能没有wget工具包,此时要是直接备份yum源会报错:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.
Run “yum repolist all” to see the repos you have.
You can enable repos with yum-config-manager —enable

所以先确保已经安装wget工具包后再备份yun源。

发表评论

表情:
评论列表 (有 0 条评论,443人围观)

还没有评论,来说两句吧...

相关阅读