缘起:由于经常安装Debian12系统,为省得每次都上网搜索查找源,于是做了个Note来方便更换源

修改/etc/apt/source.list

vim /etc/apt/source.list或者nano /etc/apt/source.list

腾讯云源

1
2
3
4
5
6
7
8
deb https://mirrors.cloud.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.cloud.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.cloud.tencent.com/debian-security/ bookworm-security main
deb-src https://mirrors.cloud.tencent.com/debian-security/ bookworm-security main
deb https://mirrors.cloud.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.cloud.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.cloud.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.cloud.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib

阿里云源

1
2
3
4
5
6
7
8
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib

清华大学源

1
2
3
4
5
6
7
8
deb https://mirrors.tsinghua.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.tsinghua.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.tsinghua.edu.cn/debian-security/ bookworm-security main
deb-src https://mirrors.tsinghua.edu.cn/debian-security/ bookworm-security main
deb https://mirrors.tsinghua.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.tsinghua.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.tsinghua.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.tsinghua.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib

中科大源

1
2
3
4
5
6
7
8
deb https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib

网易云源

1
2
3
4
5
6
7
8
deb https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian-security/ bookworm-security main
deb-src https://mirrors.163.com/debian-security/ bookworm-security main
deb https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib

Debian 12 的容器系统更换 APT 源(即Debian 云映像)(摘自:https://blog.csdn.net/qq_34718871/article/details/134218667)

前情提要

自 Debian 12 (bookworm) 开始,Debian 的容器镜像开始使用 DEB822 格式,而非之前的单行格式。该更改目前只被作用于诸如 Docker Image 之类的容器镜像,传统意义上的 Debian 操作系统不受影响。原先应该修改的 /etc/apt/sources.list 文件现在已被移除。现在,默认源的相关配置已被移至 /etc/apt/sources.list.d/debian.sources 文件。

1
2
3
4
5
6
7
8
9
10
11
12
13
Types: deb
# http://snapshot.debian.org/archive/debian/20230919T000000Z
URIs: http://deb.debian.org/debian
Suites: bookworm bookworm-updates
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
# http://snapshot.debian.org/archive/debian-security/20230919T000000Z
URIs: http://deb.debian.org/debian-security
Suites: bookworm-security
Components: main
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

修改 APT 源

修改软件源的方法和以前几乎相同,最便捷的方式依然是使用 sed 命令进行文本替换。为了方便阁下使用,特列出一些常用源。直接复制命令至 Dockerfile 等地即可使用。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 华为云 Huawei Cloud
sed -i 's@deb.debian.org@repo.huaweicloud.com@g' /etc/apt/sources.list.d/debian.sources
# 阿里云 Aliyun(限速)
sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources
# 腾讯云 Tencent Cloud(限速)
sed -i 's@deb.debian.org@mirrors.cloud.tencent.com@g' /etc/apt/sources.list.d/debian.sources
# 清华大学 TSINGHUA TUNA(北京地区推荐)
sed -i 's@deb.debian.org@mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list.d/debian.sources
# 中科大 USTC
sed -i 's@deb.debian.org@mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/debian.sources
# 南京大学 NJU
sed -i 's@deb.debian.org@mirror.nju.edu.cn@g' /etc/apt/sources.list.d/debian.sources
# 上海交大 SJTU(上海地区推荐)
sed -i 's@deb.debian.org@mirror.sjtu.edu.cn@g' /etc/apt/sources.list.d/debian.sources
# 香港 xTom(仅限香港特别行政区)
sed -i 's@deb.debian.org@mirror.xtom.com.hk@g' /etc/apt/sources.list.d/debian.sources

更新软件源

sudo apt update