Centos、Ubuntu、Debian、Fedora、OpenSUSE、FreeBSD系统换软件源
Linux系统安装完后软件源一般都是国外服务器,在国内特别慢,这时候就需要更换国内的镜像源。
高性价比和便宜的VPS/云服务器推荐:https://blog.zeruns.tech/archives/383.html
Centos
1、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、更换源
下载新的CentOS-Base.repo
到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
注意http://mirrors.aliyun.com/repo/Centos-7.repo
中的7
改为自己的Centos版本号,比如Centos 8就是http://mirrors.aliyun.com/repo/Centos-8.repo
。
3、运行yum makecache生成缓存
yum makecache
Ubuntu
1.备份
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
将以前的源备份一下,以防以后可以用的。
2.更改文件权限使其可编辑
sudo chmod 777 /etc/apt/source.list
3.更换源
sudo nano /etc/apt/sources.list
使用nano打开文本,删除原来文件里的内容,将下面其中一个源复制进去,然后保存。
阿里源: