第 9 章 Managing custom software repositories


You can configure a repository in the /etc/dnf/dnf.conf file or in a .repo file in the /etc/yum.repos.d/ directory.

The /etc/dnf/dnf.conf file contains the [main] section and can contain one or more repository sections with a unique repository ID in brackets ([]), for example, ([<repository-ID>]). You can use these sections to define individual DNF repositories by setting repository-specific options. Note that repository IDs must be unique. The values you define in individual repository sections of the /etc/dnf/dnf.conf file override values set in the [main] section for this repository.

For a complete list of available repository ID options, see the [<repository_ID>] OPTIONS section of the dnf.conf(5) man page.

Consider adding your custom repositories in separate .repo files instead of the /etc/dnf/dnf.conf DNF configuration file to avoid possible issues if other programs modify the DNF configuration file.

You can add the DNF repository to your system by using the dnf config-manager --add-repo command. Repositories that you add with this command are enabled by default. However, you can also use the dnf config-manager command to disable the repository.

警告

Obtaining and installing software packages from unverified or untrusted sources other than Red Hat certificate-based Content Delivery Network (CDN) is a potential security risk, and can lead to security, stability, compatibility, and maintainability issues.

Procedure

  1. Add a repository to your system:

    # dnf config-manager --add-repo <repository_URL>
  2. Review and, optionally, update the repository settings that the previous command created in the /etc/yum.repos.d/<repository_URL>.repo file:

    # cat /etc/yum.repos.d/<repository_URL>.repo
  3. Optional: Disable the DNF repository added to your system:

    # dnf config-manager --disable <repository_ID>

    To re-enable the repository, enter:

    # dnf config-manager --enable <repository_ID>
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部