Debian9.4更换源的正确姿势

本文提供了详细的步骤来更换Debian系统的软件源至国内镜像站点,包括备份原配置文件、删除旧源配置、添加新的国内源配置并更新软件包列表。

#备份原有的源配置文件

$ cp /etc/apt/sources.list /etc/apt/sources.listbak 

#删除该源配置文件

$ rm -f /etc/apt/sources.list

#生成国内的源配置文件

$ echo "deb http://ftp.cn.debian.org/debian/ stretch main" > /etc/apt/sources.list
$ echo "deb http://ftp.cn.debian.org/debian/ stretch-updates main" >> /etc/apt/sources.list 
$ echo "deb http://ftp.cn.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list

#更新源

$ apt-get update


debian的全球镜像站:

https://www.debian.org/mirror/list

目前并没有 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]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值