Debian 10 安装全攻略,如何更换软件源(含安装时与安装后)

admin

Debian 10 (Buster) 以其极高的稳定性和安全性著称,是全球服务器和开发环境的首选之一,对于国内用户而言,Debian 官方默认的软件源服务器位于国外,下载速度往往不尽如人意,甚至出现连接超时的情况,在安装 Debian 10 时或安装完成后,更换为国内的高速镜像源是提升体验的关键一步。

本文将详细介绍两种更换源的方法:一种是在安装系统过程中直接设置,另一种是安装完成后手动更换。

安装时更换源(最便捷的方式)

在 Debian 10 的安装程序(Debian Installer)中,安装向导已经贴心地支持了更换镜像地址的功能,这能确保你安装的系统自带的就是国内源,省去了后续修改的麻烦。

Debian 10 安装全攻略,如何更换软件源(含安装时与安装后)

  1. 在安装语言选择界面,选择中文(或你需要的语言)。
  2. 在安装器类型(Installer type)界面,选择 “图形化安装”“CLI 模式”(根据个人喜好,推荐图形化)。
  3. 在“分区”界面完成分区操作后,系统会提示“正在安装内核”。
  4. 关键步骤: 在安装内核之后,安装程序会询问你“镜像地址”。
    • 选择 “国内镜像”
    • 在列表中选择一个你熟悉的国内镜像站点,
      • 清华大学镜像站
      • 阿里云镜像站
      • 中科大镜像站
  5. 确认选择后,安装程序会自动下载包含国内源的软件包列表,后续的软件安装速度将大幅提升。

安装后更换源(最通用的方式)

如果你已经安装完成,或者安装时没有选择国内镜像,也可以在系统安装好后手动修改,Debian 10 的源配置文件位于 /etc/apt/sources.list

备份原配置文件

在进行任何修改前,建议先备份原文件,以防误操作导致系统无法更新:

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

编辑源配置文件

使用你喜欢的编辑器打开文件(这里使用 nano,也可以用 vim):

sudo nano /etc/apt/sources.list

替换为国内源内容

打开文件后,你会发现里面是类似 deb http://deb.debian.org/debian/ buster main contrib non-free 的链接,你需要将其全部替换为国内镜像站的地址。

以下提供三个常用国内源的配置内容,你可以根据需要复制粘贴:

方案 A:阿里云镜像源

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

方案 B:清华大学镜像源

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.tsing
文章版权声明:除非注明,否则均为xmsdn原创文章,转载或复制请以超链接形式并注明出处。

取消
微信二维码
微信二维码
支付宝二维码