温馨提示×

Debian软件源配置指南

小樊
41
2025-08-22 11:13:43
栏目: 智能运维

以下是Debian软件源配置指南:

备份原始文件

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

配置国内源(以清华源为例)

  • 方法一:直接编辑/etc/apt/sources.list
    sudo nano /etc/apt/sources.list
    
    将内容替换为(根据系统版本替换bookworm等代号):
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
    deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
    
  • 方法二:使用DEB822格式(推荐)/etc/apt/sources.list.d/目录下创建.sources文件,如debian.sources
    sudo nano /etc/apt/sources.list.d/debian.sources
    
    添加内容:
    Types: deb deb-src
    URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
    Suites: bookworm bookworm-updates bookworm-security
    Components: main contrib non-free non-free-firmware
    Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
    

更新软件包列表

sudo apt update

0