树莓派更改软件源为清华源
1. 备份原有的 sources.list 文件
在开始之前,最好备份原有的 sources.list 文件,以防万一需要恢复。
打开终端,执行以下命令来备份原有的 sources.list 文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2. 编辑 sources.list 文件
接下来,我们需要编辑 /etc/apt/sources.list 文件,将其替换为清华大学的镜像源地址。
使用文本编辑器打开 sources.list 文件,例如使用 nano:
sudo nano /etc/apt/sources.list
3. 修改 sources.list 文件
在文件中清空原有内容,并添加清华大学的镜像源地址。将以下内容粘贴到文件中:
#默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
#deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
#deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
#deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
#以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
#deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
个人计算机按你树莓派版本 确定 buster 或 bookworm 或其他
4.可能会出现 no public-key 问题
由于没有公钥,无法验证下列签名: NO_PUBKEY 9165938D90FDDD2E
使用 apt-key 导入公钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E
具体key个人计算机会有所不同
5 修改其他文件
/etc/apt/sources.list.d/raspi.list
内容修改为
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main
6.更新源
sudo apt-get update