首页/系统/Linux 运维命令速查/仓库配置(yum.repos.d 与 sources.list)
本包目录(613 条)

仓库配置(yum.repos.d 与 sources.list)

包从哪来由仓库定义:RHEL 系 /etc/yum.repos.d/*.repo、Debian 系 /etc/apt/sources.list(.d);启用/禁用与优先级都在这里。

Linux 运维命令速查系统更新于 2026-10-12
用途配置包管理器的软件源
语法编辑 .repo 文件 / sources.list
所属dnf/yum 与 APT

yum repo 模板

yum repo 模板
[epel]
name=Extra Packages for Enterprise Linux
baseurl=https://mirrors.example.com/epel/9/Everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
module_hotfixes=1

apt 源模板

apt 源模板
# /etc/apt/sources.list.d/internal.list
deb https://mirrors.example.com/ubuntu noble main restricted universe
deb https://mirrors.example.com/ubuntu noble-updates main restricted

生效与验证

生效与验证
dnf repolist -v
dnf config-manager --set-disabled epel        # (dnf-plugins-core)
apt update && apt-cache policy
GPG 校验(gpgcheck=1)是底线:关校验省事但把供应链风险请进门。

易错点

  • $releasever/$basearch 变量拼错导致 404;先 curl -I 试 baseurl 再保存
  • 内网镜像同步滞后时新包找不到:策略上区分「稳定源」与「临时源」并记录启用窗口

数据来源与参考

  • man 5 dnf.conf
  • man 5 sources.list(APT)
  • Red Hat 文档:自定义仓库

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌