使用说明
警告
操作前请做好相应备份
一般情况下,将 /etc/apt/sources.list 文件中 Debian 默认的源地址 http://deb.debian.org/ 替换为 http://mirrors.ustc.edu.cn 即可。
可以使用如下命令:
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
当然也可以直接编辑 /etc/apt/sources.list 文件(需要使用 sudo)。以下是 Debian Stable 参考配置内容:
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
同时你也可能需要更改 Debian Security 源,请参考 Debian Security 源使用帮助
更改完 sources.list 文件后请运行 sudo apt-get update
更新索引以生效。
小技巧
使用 HTTPS 可以有效避免国内运营商的缓存劫持,但需要事先安装 apt-transport-https (Debian Buster 及以上版本不需要)。