更换 Debian 软件更新源

确认 Debian 版本

$ cat /etc/os-release               
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

括号里的buster就是版本信息。

获取镜像地址

打开debian | 清华大学开源软件镜像站,选择buster版本,复制所有镜像地址。

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free

备份原文件

这也算是系统文件的一部分,还是保险一点,出错了再改回来。

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

打开并修改

sudo vim /etc/apt/sources.list

vim用的不习惯的估计会和我一样找全选内容怎么操作。教给你了
在命令模式下,就是按一下esc键,然后输入ggvG。具体什么含义看VIM 笔记吧,选择后直接delete删除,镜像地址粘贴进去。保存退出。

更新

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade