先确保有wget的情况下:
1.首先备份当前配置文件
(通过改名的方式备份源文件:
CentOS-Base.repo改成了
CentOS-Base.repo.backup
)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d
对于CentOS8
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
对于CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3. 运行 yum makecache 生成缓存
(将服务器上的软件包信息在本地缓存,以提高搜索和安装软件的速度)
yum makecache
4、升级yum
(-y,默认同意)
yum update -y