Debian如何更换apt源

换源,或许也适合其它Linux系统

为什么要换源?

  • 有人就有家,有家就有墙,并且我们的墙是伟大的,翻过墙太费事,因为墙外有的墙内也有,所以这里我们可以换成家里的源,速度快!

怎么更换apt源,换源方式

一般情况下,这个方法适用于所有的Linux系统,只需要修改/etc/apt/sources.list文件,这里我以Debian系统作为例子给大家演示一下。

方案一、使用sed命令

sed -i "s@http://deb.debian.org@https://mirrors.163.com@g" /etc/apt/sources.list
或者
sed -i 's/security-cdn.debian.org/mirrors.aliyun.com' /etc/apt/sources.list

如果使用的https源,则需要执行apt install apt-transport-https,再执行apt update更新源索引

方案二、

这个方案就是直接在sources.list文件里边改

打开sources.list文件

sudo nano /etc/apt/sources.list
或(用哪个编辑器看自己的喜好)
sudo vim /etc/apt/sources.list
修改之后,保存就可以了,后面是给大家的常用源

常用国内apt源地址、

163镜像源

deb http://mirrors.163.com/debian/ stretch main non-free contrib
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
中科大镜像源

deb https://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib
deb https://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib
deb https://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib
deb-src https://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib
deb-src https://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib
deb-src https://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib
deb https://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free contrib
deb-src https://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free contrib
阿里云镜像源

deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib
华为云镜像源

deb https://mirrors.huaweicloud.com/debian/ stretch main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ stretch-updates main non-free contrib
deb https://mirrors.huaweicloud.com/debian/ stretch-backports main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ stretch main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ stretch-updates main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian/ stretch-backports main non-free contrib
deb https://mirrors.huaweicloud.com/debian-security/ stretch/updates main non-free contrib
deb-src https://mirrors.huaweicloud.com/debian-security/ stretch/updates main non-free contrib
清华大学云镜像源

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main non-free contrib
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main non-free contrib
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main non-free contrib
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main non-free contrib
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main non-free contrib
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main non-free contrib
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main non-free contrib
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main non-free contrib
兰州大学云镜像源

deb http://mirror.lzu.edu.cn/debian/ stretch main non-free contrib
deb http://mirror.lzu.edu.cn/debian/ stretch-updates main non-free contrib
deb http://mirror.lzu.edu.cn/debian/ stretch-backports main non-free contrib
deb-src http://mirror.lzu.edu.cn/debian/ stretch main non-free contrib
deb-src http://mirror.lzu.edu.cn/debian/ stretch-updates main non-free contrib
deb-src http://mirror.lzu.edu.cn/debian/ stretch-backports main non-free contrib
deb http://mirror.lzu.edu.cn/debian-security/ stretch/updates main non-free contrib
deb-src http://mirror.lzu.edu.cn/debian-security/ stretch/updates main non-free contrib
上海交通大学云镜像源

deb https://mirror.sjtu.edu.cn/debian/ stretch main non-free contrib
deb https://mirror.sjtu.edu.cn/debian/ stretch-updates main non-free contrib
deb https://mirror.sjtu.edu.cn/debian/ stretch-backports main non-free contrib
deb-src https://mirror.sjtu.edu.cn/debian/ stretch main non-free contrib
deb-src https://mirror.sjtu.edu.cn/debian/ stretch-updates main non-free contrib
deb-src https://mirror.sjtu.edu.cn/debian/ stretch-backports main non-free contrib
deb https://mirror.sjtu.edu.cn/debian-security/ stretch/updates main non-free contrib
deb-src https://mirror.sjtu.edu.cn/debian-security/ stretch/updates main non-free contrib
THE END
分享
二维码
< <上一篇
下一篇>>