linux centos&Ubuntu&RedHat更换软件源

linux三大版本更换软件源

前排提示,有的源可能已经失效,如果发现请留言或自行寻找其他源。

1.centos

mv /etc/yum.repos.d/CentOS-Base.repo [--path]
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache

2.Ubuntu

备份原有软件源sudo cp /etc/apt/sources.list <路径>
sudo vi /etc/apt/sources.list
修改为以下:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

执行更新源sudo apt update

如果有其他错误,可以执行 

sudo rm -rf /var/lib/dpkg/info
sudo mkdir /var/lib/dpkg/info

3.RedHat(红帽)更换yum源。

鉴于红帽的软件源需要注册,可以更换为centos的yum。

删除自带的yum

rpm -aq | grep yum | xargs rpm -e –nodeps 

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm 

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-updateonboot-1.1.30-41.el6.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-utils-1.1.30-41.el6.noarch.rpm

rpm -Uvh python-urlgrabber-3.9.1-11.el6.noarch.rpm

rpm -ivh yum-*

cd /etc/yum.repos.d/ 

wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo

vi CentOS6-Base-163.repo

:%s/$releasever/6/g

保存退出后

yum clean all

yum makecache

验证

yum install telnet

原文地址:https://www.cnblogs.com/chxwkx/p/10945373.html