/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
/etc/yum.confThe /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
/etc/yum.confHere 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=3Key Directives in /etc/yum.conf
/etc/yum.confcachedir: Specifies the directory where YUM stores downloaded packages and cache data. The$basearchand$releasevervariables are automatically replaced with the appropriate architecture and release version of the distribution.cachedir=/var/cache/yum/$basearch/$releaseverkeepcache: Determines whether YUM should keep the cache of packages after installation. Set to0to remove cached packages after installation, and1to keep them.keepcache=0debuglevel: Sets the level of debugging information in the YUM output. Ranges from0(no debugging) to10(most verbose).debuglevel=2logfile: Specifies the path to the log file where YUM logs its actions.logfile=/var/log/yum.logexactarch: When set to1, YUM will only install packages that match the system's architecture.exactarch=1obsoletes: When set to1, YUM will allow obsoleting of packages. This is useful for distribution upgrades.obsoletes=1gpgcheck: When set to1, YUM will perform a GPG signature check on packages to ensure their authenticity and integrity.gpgcheck=1plugins: When set to1, YUM will enable the use of YUM plugins.plugins=1installonly_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 package2includepkgs: Only includes specified packages for installation or updates.includepkgs=package1 package2proxy: Specifies a proxy server to use for HTTP and HTTPS connections.proxy=http://proxy.example.com:8080proxy_usernameandproxy_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-exampleConclusion
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