/etc/yum.conf

The /etc/yum.conf file is the main configuration file for the YUM (Yellowdog Updater, Modified) package manager, used in Red Hat-based Linux distributions such as Fedora, CentOS, and RHEL. This file contains global configuration options that control the behavior of the YUM package manager.

Structure of /etc/yum.conf

The /etc/yum.conf file is a plain text file and is usually divided into sections, with each section containing key-value pairs. The most common section is [main], which defines global settings.

Example /etc/yum.conf

Here is an example of what the /etc/yum.conf file might look like:

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3

Key Directives in /etc/yum.conf

  • cachedir: Specifies the directory where YUM stores downloaded packages and cache data. The $basearch and $releasever variables are automatically replaced with the appropriate architecture and release version of the distribution.

    cachedir=/var/cache/yum/$basearch/$releasever
  • keepcache: Determines whether YUM should keep the cache of packages after installation. Set to 0 to remove cached packages after installation, and 1 to keep them.

    keepcache=0
  • debuglevel: Sets the level of debugging information in the YUM output. Ranges from 0 (no debugging) to 10 (most verbose).

    debuglevel=2
  • logfile: Specifies the path to the log file where YUM logs its actions.

    logfile=/var/log/yum.log
  • exactarch: When set to 1, YUM will only install packages that match the system's architecture.

    exactarch=1
  • obsoletes: When set to 1, YUM will allow obsoleting of packages. This is useful for distribution upgrades.

    obsoletes=1
  • gpgcheck: When set to 1, YUM will perform a GPG signature check on packages to ensure their authenticity and integrity.

    gpgcheck=1
  • plugins: When set to 1, YUM will enable the use of YUM plugins.

    plugins=1
  • installonly_limit: Limits the number of versions of each package that can be installed simultaneously. This is particularly useful for limiting the number of kernel versions on the system.

    installonly_limit=3

Additional Configuration Options

  • exclude: Excludes specific packages from being installed or updated.

    exclude=package1 package2
  • includepkgs: Only includes specified packages for installation or updates.

    includepkgs=package1 package2
  • proxy: Specifies a proxy server to use for HTTP and HTTPS connections.

    proxy=http://proxy.example.com:8080
  • proxy_username and proxy_password: Credentials for the proxy server.

    proxy_username=myusername
    proxy_password=mypassword

Managing Repositories

In addition to the global configuration in /etc/yum.conf, YUM repositories are typically defined in separate .repo files located in the /etc/yum.repos.d/ directory. Each repository file contains configuration options specific to that repository.

Example Repository File

Here is an example of a repository configuration file /etc/yum.repos.d/example.repo:

[example-repo]
name=Example Repository
baseurl=http://repo.example.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.example.com/RPM-GPG-KEY-example

Conclusion

The /etc/yum.conf file is an essential configuration file for the YUM package manager, allowing you to control various global settings for package management on Red Hat-based systems. Understanding and configuring this file correctly can help optimize your system's package management processes.

Last updated