Debian 之 更换源

本文指导如何备份Debian默认的Apt源列表,解决用户不在sudoers问题,然后清空并添加阿里云镜像源,最后更新源列表。

cp /etc/apt/sources.list /etc/apt/sources.list.bak(备份默认源)

sudo nano /etc/apt/sources.list  (编辑源列表文件)

注意:此处若提示:“用户不在 sudoers 文件”,请参考我的文章:Debian 之 “用户不在 sudoers 文件”

清空源列表文件内容,复制下面内容到源列表文件
deb https://mirrors.aliyun.com/debian stable main contrib non-free
deb https://mirrors.aliyun.com/debian stable-updates main contrib non-free

apt-get update(更新源列表)

目前并没有 Debian 19 这个版本,一般常见的有 Debian 10(buster)、Debian 11(bullseye)、Debian 12(bookworm)等。以 Debian 11 为例,若要将软件更换为中科大的 http 镜像,可按以下步骤操作: 1. 暂时改用 http 的,把 ca-certificates 安装上。 2. 修改 `/etc/apt/sources.list` 文件,使用中科大的 http debian 镜像: ```plaintext deb http://mirrors.ustc.edu.cn/debian bullseye main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian bullseye main contrib non-free deb http://mirrors.ustc.edu.cn/debian bullseye-updates main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian bullseye-updates main contrib non-free deb http://mirrors.ustc.edu.cn/debian bullseye-proposed-updates main contrib non-free deb-src http://mirrors.ustc.edu.cn/debian bullseye-proposed-updates main contrib non-free ``` 3. 更新: ```bash apt-get update ``` 4. 安装 ca-certificates: ```bash apt install ca-certificates ``` 若使用的是 Debian 12,要更换为清华大学镜像,需要将配置中的 `bullseye` 替换为 `bookworm`,具体配置如下: ```plaintext deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free ``` 之后同样执行 `apt-get update` 来更新 [^2][^4]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值