Debian 11 换国内镜像源教程

因为debian官方软件源在国外,如果你用的国内服务器,那么当你安装一个软件或者apt update的时候,你会感到那安装速度非常感人。所以在安装完 Deiban 系统后的首要事情就是更换为国内的镜像源,能显著提高软件安装和系统更新速度。本文收集了4个好用的国内镜像源供大家选择。

可用的国内镜像源列表

阿里云

deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

腾讯云

deb https://mirrors.tencent.com/debian/ bullseye main non-free contribdeb-src https://mirrors.tencent.com/debian/ bullseye main non-free contribdeb https://mirrors.tencent.com/debian-security/ bullseye-security maindeb-src https://mirrors.tencent.com/debian-security/ bullseye-security maindeb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contribdeb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contribdeb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contribdeb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib

 清华大学

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-freedeb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-freedeb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-freedeb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-freedeb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

华为云

deb https://mirrors.huaweicloud.com/debian/ bullseye main non-free contribdeb-src https://mirrors.huaweicloud.com/debian/ bullseye main non-free contribdeb https://mirrors.huaweicloud.com/debian-security/ bullseye-security maindeb-src https://mirrors.huaweicloud.com/debian-security/ bullseye-security maindeb https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contribdeb-src https://mirrors.huaweicloud.com/debian/ bullseye-updates main non-free contribdeb https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contribdeb-src https://mirrors.huaweicloud.com/debian/ bullseye-backports main non-free contrib

手动更换镜像源

手动更换 Debian 镜像源配置主要分为以下三步:

  1. 用熟悉的文本编辑器打开 /etc/apt/sources.list 文件(需要 sudo 权限),或是直接执行 sudo apt edit-sources 命令。
  2. 替换文件内容为上面任意一个镜像站的源配置代码并保存。
  3. 运行 sudo apt-get update 命令更新软件索引。

一键更换镜像源

使用命令替换镜像源更为快捷。比如在没有更换过数据源的情况下,要使用阿里云的 Debian 镜像源:

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

这样就完成了默认源到阿里云镜像源的配置。接下来同样需要执行一下 sudo apt-get update 命令更新软件索引。

上面这个命令的原理在镜像源的地址上。不同的镜像源通常只是域名有所区别,其他部分大致类似。所以之需要通过 sed 命令来修改 /etc/apt/sources.list 这个源配置文件中的域名地址就足够了。

但这意味着使用这个命令方式修改镜像源的配置时需要格外注意。如果输入的匹配地址或替换地址有误,有可能不会生效,或是导致镜像源异常。遇到这种情况,可以选择上面手动更换镜像源的方式来解决。

分享技巧

Docker官方镜像仓库被墙无法连接有效解决办法

2023-6-18 0:36:22

分享技巧

Azure100 开通免费的虚拟机指南

2023-6-26 14:38:37

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索