Centos7.6如何更换软件源
最近更新时间:2024-06-23 05:53:38
首先连接SSH终端教程地址:https://hmyun.com.cn/news/detail/support/54
第一步执行
sudo cp /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
备份原软件源
![lxqnd86t.png lxqnd86t.png](https://cos.jxhmxxjs.com/blog/typecho/lxqnd86t.png-123)
第二步执行
sudo yum clean all
清除yum缓存
![lxqndpqv.png lxqndpqv.png](https://cos.jxhmxxjs.com/blog/typecho/lxqndpqv.png-123)
第三步执行
sudo vi /etc/yum.repos.d/CentOS-Base.repo
![lxqnf6cj.png lxqnf6cj.png](https://cos.jxhmxxjs.com/blog/typecho/lxqnf6cj.png-123)
按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 试试是否有效 有效即可
![lxqnfo9h.png lxqnfo9h.png](https://cos.jxhmxxjs.com/blog/typecho/lxqnfo9h.png-123)