树莓派4B 零起点(二) 树莓派 更换软件源和软件仓库

目录

一、准备工作,查看自己的树莓派版本

二、安装HTTPS支持

三、更换为清华源

1、更换Debian软件源

2,更换Raspberrypi软件仓库

四、进行软件更新


接前章,我们的树莓派已经启动起来了,接下来要干的事那就是更换软件源和软件仓库,更换国内的镜像可以大大提高软件下载速度,提升我们的使用体验。

说干就干,方法如下:(无屏操作的话,请先使用Xshell等ssh工具连接上树莓派)

一、准备工作,查看自己的树莓派版本

bash 复制代码
lsb_release -a

请看到 Codename 这一行,我的树莓派4B的系统版本名称那就是 bookworm 了。

以下是常见的几个树莓派4B的版本,注意不同版本的源是不一样的

Debian 12(bookworm) --- 树莓派4 当前稳定(stable)版

Debian 11(bullseye)--- 树莓派4 旧的 稳定(stable)版

Debian 10(buster)--- 树莓派 4 早期 稳定(oldstable)版

二、安装HTTPS支持

Debian Buster 以上版本一般是默认已支持 HTTPS 源,我们再进一步直接安装确认一下

bash 复制代码
sudo apt install apt-transport-https ca-certificates

我的是已经默认已支持的状态,如下图

三、更换为清华源

1、更换Debian软件源
  1. 访问清华大学开源软件Debian镜像站

https://mirrors.tuna.tsinghua.edu.cn/help/debian/https://mirrors.tuna.tsinghua.edu.cn/help/debian/

2)按照前面查看到的 系统版本 选择 对应的 源 内容:

3)在终端里编辑 /etc/apt/sources.list

bash 复制代码
sudo nano /etc/apt/sources.list

如下图所示,将原有的内容前加 # 注释掉,再 将 清华源网站上的 内容 复制到该文件中

如果你的版本和我的版本一样也是 bookworm,可以直接复制下面的内容,加在后面:

bash 复制代码
# 默认注释了源码镜像以提高 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://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

在这里特别说明两点:

a. 如果是为了快速配置,debian-security的配置可以采用镜像站,但如果是为了保证安全更新更快能得到更新,则建议仍然使用原有的安全软件源,因为镜像站可能会有同步延迟

b. 一般默认是注释了源码镜像的,主要是为了提高 apt update 速度,如有项目需要可自行取消注释

  1. 修改完成,保存退出

在nano编辑器里操作, Ctrl+O (保存), Ctrl+X (退出),此时就完成了Debian软件源的更换

2,更换Raspberrypi软件仓库
  1. 访问清华大学开源软件Raspberrypi镜像

https://mirrors.tuna.tsinghua.edu.cn/help/raspberrypi/https://mirrors.tuna.tsinghua.edu.cn/help/raspberrypi/

2)按照前面查看到的 系统版本 选择 对应的 源 内容:

3)在终端里编辑 /etc/apt/sources.list.d/raspi.list

bash 复制代码
​sudo nano /etc/apt/sources.list.d/raspi.list

​

如下图所示,将原有的内容前加 # 注释掉,再 将 清华源网站上的 内容 复制到该文件中

如果你的版本和我的版本一样也是 bookworm,可以直接复制下面的内容,加在后面:

bash 复制代码
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main
#deb-src https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main
  1. 修改完成,保存退出

在nano编辑器里操作, Ctrl+O (保存), Ctrl+X (退出),此时就完成了Raspberrypi软件仓库的更换

四、进行软件更新

bash 复制代码
sudo apt-get update
sudo apt-get upgrade 

如有提示键入 Y ,进行更新,可能会花费一点时间,请耐心等待更新完成。

相关推荐
Lw老王要学习3 分钟前
Linux容器篇、第二章_01Ubuntu22 环境下 KubeSphere 容器平台高可用搭建全流程
linux·运维·服务器·k8s·kubesphere·容器化
張萠飛34 分钟前
Linux下如何使用shell脚本导出elasticsearch中某一个index的数据为本地csv文件
linux·运维·elasticsearch
lingzhilab38 分钟前
零知开源——STM32F103RBT6驱动 ICM20948 九轴传感器及 vofa + 上位机可视化教程
stm32·嵌入式硬件·信息可视化
奔跑吧邓邓子1 小时前
DeepSeek 赋能智能养老:情感陪伴机器人的温暖革新
人工智能·机器人·deepseek·智能养老·情感陪伴
晓枫-迷麟2 小时前
【nano与Vim】常用命令
linux·编辑器·vim
LucienShui3 小时前
Webhook 配置备忘
linux·运维·webhook
超级土豆粉3 小时前
从0到1写一个适用于Node.js的User Agent生成库
linux·ubuntu·node.js
PH_modest3 小时前
【Linux跬步积累】—— 网络编程套接字(二)
linux·运维·网络
VR最前沿4 小时前
全新Xsens Animate版本是迄今为止最大的软件升级,提供更清晰的数据、快捷的工作流程以及从录制开始就更直观的体验
人工智能·科技·机器人·自动化
CIb0la4 小时前
Ubuntu 25.10 将默认使用 sudo-rs
linux·程序人生·生活