linux 更换yum源为阿里云源

 

先看一下我的centos系统版本,用命令  cat /etc/issue

linux 更换yum源为阿里云源

然后正式开始:

第一步先备份原有的镜像文件,防止出错后无法恢复。

mv/etc/yum.repos.d/CentOS-Base.repo/ etc/yum.repos.d/CentOS-Base.repo.backup

第二步下载新的CentOS-Base.repo 到/etc/yum.repos.d/


命令为:wget -O /etc/yum.repos.d/CentOS-Base.repo linux 更换yum源为阿里云源http://mirrors.aliyun.com/repo/Centos-6.repo

(如果提示 bash: wget: command not found 则需要先恢复移走的镜像文件,把wget安装上,执行命令yum -y install wget及安装成功)

1)wget未安装的截图

linux 更换yum源为阿里云源

2)切回到旧的yum源后安装wget截图(切换命令 mv/etc/yum.repos.d/CentOS-Base.repo.backup/ etc/yum.repos.d/CentOS-Base.repo)

linux 更换yum源为阿里云源

3)下载新的yum源的截图,命令 wget -O /etc/yum.repos.d/CentOS-Base.repo linux 更换yum源为阿里云源http://mirrors.aliyun.com/repo/Centos-6.repo

linux 更换yum源为阿里云源

第三步生成缓存,命令 yum makecache 如果失败 先运行 yum clean all 然后运行 yum makecache

失败截图:

linux 更换yum源为阿里云源

运行yum clean all 之后在运行yum makecache  成功截图:

linux 更换yum源为阿里云源

到此更换完毕。