Modifying the Yum Configuration File
The main configuration file for yum is located at /etc/yum.conf. This file contains one mandatory [main] section, which allows you to set yum options that have global effect, and can also contain one or more [repository] sections, which allow you to set repository-specific options. Individual repositories are defined in .repo files in the /etc/yum.repos.d directory.
Configure Yum either using the yum.conf file under the /etc directory or by adding the .repo file under the /etc/yum.repos.d directory.
Setting the [Main] Section
The following is an example [main] section:
[main] cachedir=/var/cache/yum keepcache=0 debuglevel=2 logfile=/var/log/yum.log pkgpolicy=newest tolerant=1 exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=3 [comments abridged] # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d
For details about the complete [main] section, see yum.conf(5) in the online help of [main].
Option |
Description |
---|---|
cachedir=/var/cache/yum |
Yum's cache directory where downloaded RPM packages and databases are saved. Imagine you want to install a software package. Yum will download the target package from the base/packages folder in the cache directory and install it automatically. Once installed, the target package will not be automatically deleted but it can be manually deleted. |
keepcache=1 |
Determines whether Yum retains the cache of RPM packages and header files after a successful installation. Value: 0 or 1. The default value is 1 (retain the cache). If this option takes the value 1, the next time you want to install one of the RPM packages in the cache directory again, Yum will install it from the cache directory /var/cache/yum… without a need to first download it. |
reposdir |
Absolute path to the directory where .repo files are located. The default path is /etc/yum.repos.d. |
assumeyes=0 |
Determines whether Yum automatically confirms RPM package installation. Value: 0 or 1. The default value is 0 (prompt for user confirmation). |
alwaysprompt=1 |
Determines whether or not Yum always prompts for confirmation before installing an RPM package. Value: 0 or 1. The default value is 1 (always prompt for user confirmation). |
retries=2 |
The number of retries following a network connection error. Setting this option to 0 makes Yum retry forever. |
debuglevel=2 |
The level of details in the debug output produced by Yum. Value range: 1–10. A higher debug level causes Yum to display more detailed debug output. |
logfile=/var/log/yum.log |
Location of Yum log files. |
pkgpolicy=newest |
Software package selection policy in the event that multiple repositories hold the software package you want to install. Value: Newest (typical): Yum installs the latest version of the software package. Last: Yum places repository IDs in alphabetical order and installs the software package from the repository at the bottom of the alphabetical list. |
distroverpkg=redhat-release |
The package used by Yum to determine the version of the distribution. This can be any installed RPM package. The default package is redhat-release (for example, centos-release or rpmforge-release). |
tolerant=1 |
Whether Yum is tolerant of package errors on command lines. Value: 0 or 1. The default value is 0 (not tolerant). Imagine you request to install 1.i386.rpm, 2.i386.rpm, and 3.i386.rpm packages but 3.i386.rpm is already installed. Setting this option to 1 prevents Yum from reporting the error that 3.i386.rpm is already installed. |
exactarch=1 |
Determines whether Yum updates only the architectures of packages that you have installed. Value: 0 or 1. The default value is 1 (update architectures). For example, with the default value, Yum will not install an i686 package to update an i386 package. |
obsoletes=1 |
This option only has affect during an update. |
gpgcheck=1 |
Determines whether Yum performs a GPG signature check on packages. Value: 0 or 1. The default value is 1 (enable a GPG signature check). |
plugins=1 |
A switch to enable or disable Yum plug-ins (for example, python). Value: 0 or 1 (enable). |
metadata_expire=1800 exclude=…. |
The metadata_expire option specifies the time (in seconds) after which metadata will expire. The exclude option allows you to exclude packages by keyword during installation or updating. The value is either a wildcard (for example, * or ?) or a space-delimited list of software packages such as theme packages or particular patches. |
Setting the [repository] Sections
The [repository] sections allow you to define individual Yum repositories. Each Yum repository must have a unique name. Otherwise, a conflict between repositories occurs. The following is a bare-minimum example of a [repository] section:
[repository] name=repository_name baseurl=repository_url
Option |
Description |
---|---|
name=repository_name |
A string describing the repository. |
baseurl=repository_url |
Uniform resource locator (URL) to the directory where the repository is located.
|
Viewing Current Configurations
To display the current values of global Yum options, run the following command:
yum-config-manager
To view the configurations of a particular section in the Yum configuration file, run the following command:
yum-config-manager section…
You can also use a global regular expression to view the configurations of all matching sections.
yum-config-manager glob_expression…
For example, to view all configuration options and their values in the [main] section, run the following command:
$ yum-config-manager main \* Loaded plugins: langpacks, product-id, subscription-manager ================================== main =================================== [main] alwaysprompt = True assumeyes = False bandwith = 0 bugtracker_url = https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%206&component=yum cache = 0 [output truncated]