树莓派自带的源速度很慢,直接导致我们不能愉快地更新软件和系统,所以换源是很有必要的

通用更换方法(结合下方的可用源修改)

使用nano 编辑器编辑文件方便点~,Ctrl + O存盘;Ctrl + X存盘然后保存

1.首先编辑/etc/apt/sources.list文件

sudo nano /etc/apt/sources.list

2.再编辑/etc/apt/sources.list.d/raspi.list文件

sudo nano /etc/apt/sources.list.d/raspi.list
注:最好先把所有原有的东西注释掉~

更换好后请使用该命令,更新软件源列表,同时检查您的编辑是否正确

sudo apt-get update

可用源

首先apt源是基于系统发行版本来选择codename的,像下方的stretch和jessie就是发行版本codename

我们需要先运行一个命令,任选其一,第二个可以直接打印出codename

lsb_release -a
或
lsb_release -cs

获取当前发行版本的codename,然后在下方的源中使用自己的codename进行替换

1.清华源(推荐使用)

编辑/etc/apt/sources.list文件,使用以下文本添加到文件末,请先注释掉原有文本

deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

编辑/etc/apt/sources.list.d/raspi.list文件,使用以下文本添加,同样注释掉原文本

deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui

2.阿里源

同上方法编辑第一个文件sources.list

deb http://mirrors.aliyun.com/raspbian/raspbian/  jessie main contrib non-free rpi

然后更改第二个文件raspi.list

deb http://mirrors.aliyun.com/debian/ jessie main ui

对于这两个源我认为清华源要更好,如果想要用阿里源的话,你可以自行测试一下

3.科大源

sources.list

deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ jessie main contrib non-free rpi

raspi.list

deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ jessie main ui

另附树莓派官方发布的可用源列表
http://www.raspbian.org/RaspbianMirrors

文章作者:四文鱼Max

本文链接:https://blog.awolon.fun/archives/raspbian-apt-change-source.html

许可协议:CC BY-SA 4.0

标签: raspberrypi, apt

添加新评论