查询自己版本:
lsb_release -a
bullseye可以理解为树莓派的系统代号(10,11,12都不同,一定要看好自己系统是什么版本)
查询架构
uname -a
aarch64的地方就是代表系统架构的,我的是aarch64的架构。
完成上面就可以去清华源网站查找自己对应的清华源了。
查找树莓派源:mirrors.tuna.tsinghua.edu.cn/help/debian/
可以得到源:
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-firmwaredeb 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-firmwaredeb 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-firmwaredeb 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
然后打开控制台输入下面命令:
sudo nano /etc/apt/sources.list
进入该文件编辑,将里面的内容用清华源的内容覆盖掉,保存退出。(Ctrl+X键入Y,回车保存)
最后:sudo apt-get update && sudo apt-get upgrade
可能会报错:no public key available
解决问题(更换源之后添加公钥即可),执行以下命令:
gpg --keyserver keyserver.ubuntu.com --recv-keys E77FC0EC34276B4B
gpg --export --armor E77FC0EC34276B4B | sudo apt-key add -
另一种解决方法(更换源之后添加公钥即可,推荐用这个命令),执行以下命令:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E77FC0EC34276B4B