Centos7.6如何更换软件源

黎隆发
Sun, 23 Jun 2024 05:41:00 +0800

首先连接SSH终端教程地址：https://hmyun.com.cn/news/detail/support/54

第一步执行
sudo cp /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
备份原软件源

第二步执行
sudo yum clean all
清除yum缓存

第三步执行
sudo vi /etc/yum.repos.d/CentOS-Base.repo

按i 进入输入模式

删除全部内容

我们拿清华源来做演示

[base]
name=CentOS-$releasever - Base - mirrors.tuna.tsinghua.edu.cn
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.tuna.tsinghua.edu.cn
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.tuna.tsinghua.edu.cn
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.tuna.tsinghua.edu.cn
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7

复制进入 按esc 退出输入模式 输入:wq退出 vi 使用 yum install wget 试试是否有效 有效即可