centos换源
- 备份之前的源文件
# 进入Root用户
su
# 备份源文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 查看自己当前的centos版本
cat /etc/system-release
- 查看和下载对应版本的源
# 阿里源
# centos5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
# centos6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# centos7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 网易源
# centos5
wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
# centos6
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
# centos7
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
- 清空yum缓存并生存cache文件
yum clean all
yum makecache
- 更新软件
yum -y update
-
如果 wget 没有安装,运行下面命令安装 wget 软件
-
yum update --skip-broken yum -y install wget