Useful notes about Yum
A cheat sheet for working with the Yum (Yellowdog Updater, Modified) package manager which is used in popular Linux distributions: RedHat, CentOS, Scientific Linux (and others). To save space, command output is not shown.
Table of contents
Commands Yum Options Yum-utils package Config files Plugins Working through a proxy
display of commands and options
yum help
list of package names from the repository
yum list
list of all available packages
yum list available
list of all installed packages
yum list installed
is the specified package installed
yum list installed httpd
list of installed and available packages
yum list all
list of packages related to the kernel
yum list kernel
display information about the package
yum info httpd
list of dependencies and required packages
yum deplist httpd
find the package that contains the file
yum provides '*bin/top'
search for a package by name and description
yum search httpd
yum search yum
get information about available security updates
yum updateinfo list security
display a list of groups
yum grouplist
display the description and contents of the group
yum groupinfo 'Basic Web Server'
installing the “Basic Web Server” package group
yum groupinstall 'Basic Web Server'
deleting a group
yum groupremove 'Basic Web Server'
Check for available updates
yum check-update
list of connected repositories
yum repolist
information about a specific repository
yum repoinfo epel
information about packages in the specified repository
yum repo-pkgs epel list
install all packages from the repository
yum repo-pkgs reponame install
remove packages installed from the repository
yum repo-pkgs reponame remove
create cache
yum makecache
check local rpm database (dependencies, duplicates, obsoletes, provides options are supported)
yum check
yum check dependencies
viewing yum history (listing transactions)
yum history list
view information about a specific transaction (installed packages, installed dependencies)
yum history info 9
transaction cancellation
yum history undo 9
repeat
yum history redo 9
Additionally, you can view the log
cat /var/log/yum.log
remove cached packages
yum clean packages
remove all packages and metadata
yum clean all
install package
yum install httpd
package removal
yum remove httpd
update package
yum update httpd
update all packages
yum update
upgrade to a specific version
yum update-to
update from local directory
yum localinstall httpd.rpm
install from http
yum localinstall http://server/repo/httpd.rpm
rollback to a previous package version
yum downgrade
reinstall the package (recovering deleted files)
yum reinstall httpd
remove unnecessary packages
yum autoremove
create local repositories (createrepo is installed separately)
createrepo
install scheduled updates (yum-cron is installed separately)
yum cron
Yum Options
answer “yes” when prompted,
-y
yum update -y
answer “no” when prompted
--assumeno
use Yum without plugins
--noplugins
or disable a specific plugin
--disableplugin=fastestmirror
enable plugins that are installed but disabled
yum -enableplugin=ps
enable disabled repository
yum update -y -enablerepo=epel
disable repository
yum update -y -disablerepo=epel
download packages but don’t install (on Centos 7 x86_64 will be downloaded to ‘/var/cache/yum/x86_64/7/base/packages/’)
yum install httpd -downloadonly
The following commands are available after installing the yum-utils package
find which repository a package is installed from
find-repos-of-install httpd
find processes whose packages are up to date and need to be restarted
need-restarting
request to repository, find out package dependencies without installing it
repoquery -requires -resolve httpd
sync yum updates repository to local repo1 directory
reposync -p repo1 -repoid=updates
check local repository for integrity
verifytree URL
complete transactions
yum-complete-transaction
install the necessary dependencies to build the RPM package
yum-builddep
manage configuration options and yum repositories
yum-config-manager
request to local yum database, display information about the package (command used, checksum, URL from which it was set, etc.)
yumdb info httpd
download rpm packages from repository
yum downloader
download src.rpm package from repository (the corresponding repository must be included, for example in ‘/etc/yum.repos.d/CentOS-Sources.repo’ in CentOS)
yumdownloader --source php
Yum configuration files and their location
- Main config file
/etc/yum.conf
- directory, with configurations (for example, yum plugins)
/etc/yum/
- directory containing information about repositories
/etc/yum.conf.d/
Some yum.conf options:
Directory where yum stores cache and database files (default /var/cache/yum
)
cachedir=/var/cache/yum/$basearch/$releasever
Specifies whether or not Yum should keep a cache of headers and packages after a successful installation. Values: 0 or 1. (default 1)
keepcache=1
debug output level. Values: 1-10 (default 2)
debuglevel=2
log file (default ‘/var/log/yum.log’)
logfile=/var/log/yum.log
update obsolete packages
obsoletes=1
package signature verification. Values: 0 or 1 (default 1)
gpgcheck=1
enabling plugins. Values: 0 or 1 (default 1)
plugins=1
Some useful plugins
Adds command line option to view changelog before/after updates
yum-plugin-changelog
selects faster repositories from a list of mirrors
yum-plugin-fastestmirror
adds keys, keys-info, keys-data, keys-remove commands that allow you to work with keys.
yum-plugin-keys
block specified packages from updating, yum versionlock command
yum-plugin-versionlock
adding yum verify-all, verify-multilib, verify-rpm commands to verify package checksums
yum-plugin-verify
Work Yum through a proxy server
For all users:
add to the [main]
section in /etc/yum.conf
proxy='http://server:3128'
if necessary, specify a password, add
proxy_proxy_username=user
proxy_password=pass
specify proxy for individual user
export http_proxy='http://server:3128'
Read more:
man yum
man rpm