教你Debian12如何换阿里源或其他源

2024-12-09T19:42:04

前言

因为自己买了小主机,自己折腾,记录下,以免后期需要用的时候,不用翻找!

备份当前的 sources.list 文件

在开始之前,建议备份原有的源配置文件,避免误操作导致问题:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

编辑 sources.list 文件

使用你喜欢的文本编辑器编辑 /etc/apt/sources.list 文件。例如,使用 nano:

sudo nano /etc/apt/sources.list

替换为国内镜像源

将文件内容替换为以下内容,这里以常见的国内镜像站为例:
清华大学源

deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

阿里云源

deb http://mirrors.aliyun.com/debian/ bookworm main contrib non-free non-free-firmware
deb http://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware
deb http://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free non-free-firmware
deb http://mirrors.aliyun.com/debian-security bookworm-security main contrib non-free non-free-firmware

中科大源

deb http://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

选择一个国内源,将内容替换进去后保存。

更新软件包索引

sudo apt update
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »