查看: 5  |  回复: 0
  Debian 软件源替换指南
楼主
发表于 今天 14:37

 当前软件源/etc/apt/sources.list配置

deb http://ftp.us.debian.org/debian/ bookworm main non-free non-free-firmware contrib 
deb-src http://ftp.us.debian.org/debian/ bookworm main non-free non-free-firmware contrib 
deb http://ftp.us.debian.org/debian/ bookworm-updates main non-free non-free-firmware contrib 
deb-src http://ftp.us.debian.org/debian/ bookworm-updates main non-free non-free-firmware contrib 
deb http://ftp.us.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib 
deb-src http://ftp.us.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib

 当前使用的是美国FTP服务器源,可能下载速度较慢。

推荐替换命令:

阿里云镜像源

sudo sed -i 's/ftp.us.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list

具体解释:

sudo - 以管理员权限执行命令
sed -i - 使用 sed 文本处理工具直接修改文件内容
's/deb.debian.org/mmirrors.aliyun.com/g' - 替换规则:
s/ - 开始替换操作
deb.debian.org - 要被替换的原始域名(Debian 官方源)
mirrors.aliyun.com - 替换成的新域名(阿里云镜像源)
g - 全局替换(文件中所有匹配项都替换)
/etc/apt/sources.list - 要修改的文件(软件源配置文件)

清华大学镜像源

sudo sed -i 's/ftp.us.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list

中国科技大学镜像源

sudo sed -i 's/ftp.us.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

变成:

deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main non-free non-free-firmware contrib 
deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main non-free non-free-firmware contrib 
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib 
deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib 
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib 
deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib

这样就可以愉快地更新软件包了:

sudo apt update


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2026 MaNongKu.com