Linux切换源
Linux 切换源
Linux 切换源
1 centOS7的镜像源文件的目录默认都在该路径下:/etc/yum.repos.d/
1
cd /etc/yum.repos.d/
2 备份原来的yum镜像源【如果出现错误可以恢复原配置】
1
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
3 下载国内常用的镜像源并重命名为CentOS-Base.repo,将其作为当前系统的镜像源
【阿里云】
CentOS 5
1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4 添加epel源
安装 epel后,可以通过 yum install package-name安装更多软件。
1
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
5 清理缓存
yum的缓存文件的存放目录是以下路径下:/var/cache/yum 直接清空给目录,或者使用一下命令均可
1
yum clean all
6 重新生成缓存
1
yum makecache
通过以上操作yum的镜像源就更新完成了。
本文由作者按照 CC BY 4.0 进行授权