How To Configure yum

Tech Articles
Welcome Page
yum is used on versions of Linux that use the RPM Package Manager. yum is used for managing packages, package dependencies and updates.

yum originally appeared in a derivative of Red Hat Enterprise Linux called Yellow Dog Linux and was called yup (Yellow dog UPdater). yum is short for Yellow Updater, Modified.
Using yum​​​​​​​

Commonly Used yum Commands
yum list installed
list all installed packages
yum list available
list all available packages
yum list all
list installed and available packages
yum list kernel
list installed and available kernel packages yum info
list info about the package
yum deplist
list dependencies and packages providing them
yum provides
show package that provides the file (application or document)
yum search
finds packages with string in the name or descriptions
yum install
install specified package
yum update
update all packages with available updates
yum update
update the specified package
yum
erase and remove will both erase package (and possibly dependencies)

Additional yum commands
yum repolist
display enabled repositories
yum repoinfo
see info on the specified repository
yum check
check the local rpm database (time consuming)
yum localinstall
install package from local directory
yum localinstall
install package from FTP/HTTP site
yum downgrade
downgrade package to earlier version
yum reinstall
reinstall package (used for replacing deleted files)
yum swap
remove first package and replace with second package
yum
erase and remove will both erase package and possibly dependencies
yum groupinstall
Install all packages in selected group
ex: yum groupinstall “Web server”
yum show-installed
show installed RPMs and statistics
yum yum-complete-transaction
complete yum transactions that did not finish
yum history
list all yum install, update and erase actions
yum history info
show details of the specified yum transaction
yum history undo
undo action from specified transaction
yum history redo
redo undone action from specified transaction
yum clean packages
delete packages saved in cache
yum clean all
delete packages and meta data from cache


A good summary of the yum command is:
redhat yum-cheat-sheet


Configuring yum repositories
The yum configuration file is /etc/yum.conf. This file has one mandatory section and additional sections for specific repositories. The values in the repository section(s) override the settings in the main section.

The repos managed by yum are in the /etc/yum/repos.d directory.

The configuration file /etc/yum.conf has one section called [main] which is used for defining global configuration options. Also, there is at least one [repository] section.

Commonly Used Directives in the [main] section
assumeyes=<0 | 1>
0 — default, prompt for confirmation of critical actions performed by yum
1 — Behave as if the -y command line option is being used: no prompt for confirmation of critical yum actions

assumeyes=<0 | 1>
0 — default, prompt for confirmation of critical actions performed by yum
1 — Behave as if the -y command line option is being used: no prompt for confirmation of critical yum actions

cachedir=
Where Yum’s cache and database files are stored, the default is:
/var/cache/yum/$basearch/$releasever

debuglevel=<0|1|2|3|4|5|6|7|8|9|10>
an integer between 0 and 10, with 0 disabling debugging output and higher values causing yum to display more detailed debugging output. The default: debuglevel=2

exactarch=<0|1>
0 — Do not take into account the exact architecture when updating packages.
1 — (default) For example, do not install an i686 package to update an i386 package already installed on the system.

exclude= [more_package_names]
Exclude packages by keyword during installation/updates, multiple packages are space-delimited. Shell globs using wildcards (* and ?) are allowed.

gpgcheck=<0|1>
A digital signature certifies and timestamps a document. Verification of the signature confirms that the document was not subsequently modified in any way.
0 — Disables GPG signature-checking. This affects packages in all repositories, including local package installation.
1 — (Default). Enables GPG signature-checking on all packages in all repositories. GPG-checking can be enabled on one repository while disabling it on another by using this setting in the individual repository’s .repo file

groupremove_leaf_only=<0|1>
This affects package group removal. The default setting will cause all packages in that group to be removed even if they are dependencies of other groups.
0 — (default) remove all packages in a package group without checking dependencies
1 — check dependencies of each package when removing a package group, and remove only those packages which are not required by any other package or group.
For more information: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Removing.html#important-Package_Group_Removal

installonlypkgs=[space separated list of packages]
space-separated list of packages that will NOT be updated, only installed. Kernel packages should always be listed in installonlypkgs, and installonly_limit should always be set to a value greater than 2 so that a backup kernel is always available in case the default one fails to boot (these are default settings).

installonly_limit=value
…where value is an integer representing the maximum number of versions that can be installed simultaneously for any single package listed in the installonlypkgs directive.
The defaults for the installonlypkgs directive include several different kernel packages, so be aware that changing the value of installonly_limit will also affect the maximum number of installed versions of any single kernel package. The default value listed in /etc/yum.conf is installonly_limit=3, and it is not recommended to decrease this value, particularly below 2.

keepcache=<0|1>
Retention of the cache of headers and packages after a successful installation
0 — (default) Do not retain. 
1 — Retain.

logfile=
Default: /var/log/yum.log
/path/file is the absolute path to yum’s logging output. 

multilib_policy=
all: install every possible architecture for the system
best: install the best architecture for the system

obsoletes=<0 | 1>
This setting is particularly useful when packages are renamed from one version to another. 
0: turns off this functionality
1: Works when a package declares in its spec file that it obsoletes another package. The obsoleted package will be replaced by this package. 

plugins=<0 | 1>
RedHat recommends disabling plugins individually rather than globally.
0: disable all plugins globally
1: enable yum plugins globally. This setting allows individual yum plug-ins to be disabled by setting enabled=0 in that plug-in’s configuration file.

reposdir=
If not set, yum uses  /etc/yum.repos.d/
Yum collects all repository information from .repo files and the [repository] section of the /etc/yum.conf file to create a master list of repositories to use for transactions. 
This setting allows a custom location for this repo information.

retries=
Default value: 10
The number of times yum should attempt to retrieve a file before returning an error. Setting this to 0 makes yum retry forever.
 
Directories Used In [repository]
Individual Yum repositories can be defined in the [repository] sections. A repository section must have at least the following directives:
[repository]
name=
baseurl=

repository_name: a human-readable string

repository_url: the directory where the repodata directory of a repository is located. Here are the formats if the repository is local, is available over FTP, is available over HTTP or is using HTTP authentication:
file:///path/to/local/repo 
ftp://path/to/repo 
http://path/to/repo
http://user:[email protected]/repo/

Other useful [repository] directives

enabled=<0 | 1>
This setting determines if a repository is used as a package source.
0 — Do not include this repository for updates and installs
1 — Include this repository
Note that a repository can be turned on and off by passing the following options to yum on the command line:
--enablerepo=repo_name
--disablerepo=repo_name


Suggestions for Future Learning


See RHEL6 Deployment_Guide check-rpm-sig for more information on GPG signatures.

Further information about yum plug-ins:  RHEL 6 Deployment_Guide Yum_Plugins

Tech Articles
Welcome Page