We’ll cover more than a 100 commands of the yum
package manager. Which is super handy to the system-administrators in order to be able to manage the packages in Linux distros that use yum
, such as redhat 6 & 7, CentOS 6 & 7 and Scientific Linux 6 & 7.
Keep in mind that a root‘s privileges are needed. To gain those privileges, either login as root with su
if you have the root‘s password, or prefix each of the following command with sudo
if your user is a sudoer.
QueryupdateinfoRepositoriesInstallUpdate/DowngradeRemoveTroubleshootingBonus
List
List all available packages:
[root@centos ~]# yum list available
List all installed packages:
[root@centos ~]# yum list installed
List all installed & available packages:
[root@centos ~]# yum list all
List all installed & available kernel packages:
[root@centos ~]# yum list kernel
List all installed & available package groups:
[root@centos ~]# yum grouplist
Search:
Search for vim
package:
[root@centos ~]# yum search vim
Info:
List info about coreutils
package:
[root@centos ~]# yum info coreutils
List packages in Fedora Packager
group:
[root@centos ~]# yum groupinfo 'Fedora Packager'
Dependencies::
List dependencies of tmux
package:
[root@centos ~]# yum deplist tmux
Files:
Show package contains htop
command:
[root@centos ~]# yum provides '*bin/htop'
Same as:
yum whatprovides '*bin/htop'
.Show package contains README.top
file:
[root@centos ~]# yum provides "*/README.top"
Summary
Display a summary information about the advisories for packages that can be updated:
[root@centos ~]# yum updateinfo
Same as:
yum updateinfo summary
, same as: yum updateinfo summary updates
.Display a summary information only about the installed advisories:
[root@centos ~]# yum updateinfo summary installed
Display a summary information about the advisories for packages available for updating or installation:
[root@centos ~]# yum updateinfo summary available
Display a summary information about both installed and available advisories:
[root@centos ~]# yum updateinfo summary all
Info
Display a list of information about the advisories for packages that can be updated:
[root@centos ~]# yum updateinfo info
Same as:
yum updateinfo info updates
.Display an information about the advisories FEDORA-EPEL-2020-34c412d66a
:
[root@centos ~]# yum updateinfo info FEDORA-EPEL-2020-34c412d66a
Display an information only about the installed advisories:
[root@centos ~]# yum updateinfo info installed
Display an information about the advisories for packages available for updating or installation:
[root@centos ~]# yum updateinfo info available
Display an information about both installed and available advisories:
[root@centos ~]# yum updateinfo info all
List
Display a list of the advisories for packages that can be updated:
[root@centos ~]# yum updateinfo list
Same as:
yum updateinfo list updates
.Display a list of the only installed advisories:
[root@centos ~]# yum updateinfo list installed
Display a list of the advisories for packages available for updating or installation:
[root@centos ~]# yum updateinfo list available
Display a list of both installed and available advisories:
[root@centos ~]# yum updateinfo list all
Misc
Display the available security updates:
[root@centos ~]# yum updateinfo security
Display the available bug-fix updates:
[root@centos ~]# yum updateinfo bugfix
Display the available bugzillas updates:
[root@centos ~]# yum updateinfo bugzillas
Display the available CVEs updates:
[root@centos ~]# yum updateinfo cves
Display the available enhancement updates:
[root@centos ~]# yum updateinfo enhancement
Display the available recommended updates:
[root@centos ~]# yum updateinfo recommended
Display the available severity updates:
[root@centos ~]# yum updateinfo severity
Display the available new packages updates:
[root@centos ~]# yum updateinfo new-packages
Info
Display information about epel
repository:
[root@centos ~]# yum repoinfo epel
Display information about all repositories:
[root@centos ~]# yum repoinfo all
Display information about enabled repositories:
[root@centos ~]# yum repoinfo enabled
Display information about disabled repositories:
[root@centos ~]# yum repoinfo disabled
makecache
Download yum
repository data to cache:
[root@centos ~]# yum makecache
Note that
yum makecache fast
will try to make sure the repos are current (much like “yum clean expire-cache
“).List
Display all software repositories:
[root@centos ~]# yum repolist all
Display enabled software repositories:
[root@centos ~]# yum repolist
Same as:
yum repolist enabled
.Display disabled software repositories:
[root@centos ~]# yum repolist disabled
Repository's packages
List packages in epel
repository:
[root@centos ~]# yum repo-pkgs epel list
Install all packages in epel
repository:
[root@centos ~]# yum repo-pkgs epel install
Remove all packages in epel
repository:
[root@centos ~]# yum repo-pkgs epel remove
Install
Install vim-enhanced
package:
[root@centos ~]# yum install vim-enhanced
Install multiple packages:
[root@centos ~]# yum install htop tmux
Install repository's packages
Install all packages in epel
repository:
[root@centos ~]# yum repo-pkgs epel install
Swap
Remove htop
and install tmux
:
[root@centos ~]# yum swap htop tmux
Same as:
yum swap -- remove htop -- install tmux
.Remove Xfce
group and install MATE
group:
[root@centos ~]# yum swap @Xfce @MATE
Same as:
yum swap -- group remove Xfce -- group install MATE
.Localinstall
Install a local package:
[root@centos ~]# yum localinstall htop.rpm
Multiple local packages can be specified too.
Install a package from HTTP or FTP URL:
[root@centos ~]# yum localinstall http://some-domain.com/htop.rpm
Multiple URLs can be specified too.
Groupinstall
Install all packages in Security Tools
group:
[root@centos ~]# yum groupinstall "Security Tools"
Same as:
Same as:
yum group install "Security Tools"
.Same as:
yum install "@Security Tools"
.Reinstall
Re-install tmux
package:
[root@centos ~]# yum reinstall tmux
It will re-install the same installed version of
tmux
, which will replace any deleted files.Check-update
Check if there is any available updates:
[root@centos ~]# yum check-update
Update packages
Update all packages with available updates:
[root@centos ~]# yum update
Update vim-enhanced
package:
[root@centos ~]# yum update vim-enhanced
Update multiple packages:
[root@centos ~]# yum update htop tmux
Update all packages but one:
[root@centos ~]# yum update --exclude=kernel*
The short-form is:
-x
. And it can be added as much as needed.Update misc.
Apply the updates even if some dependencies will be missing:
[root@centos ~]# yum update --skip-broken
Apply the updates without checking GPG
signatures:
[root@centos ~]# yum update --nogpgcheck
Update types
Apply security-related package updates:
[root@centos ~]# yum update --security
Apply only the bug-fix updates:
[root@centos ~]# yum update-minimal
Same as:
yum update --bugfix
.Apply only the patches and bug-fix updates:
[root@centos ~]# yum update-minimal --security
Same as:
yum update --bugfix --security
.Update-to
Update a package to a specific version:
[root@centos ~]# yum update-to tmux-1.8-4.el7
Downgrade
Downgrade htop
package to earlier version:
[root@centos ~]# yum downgrade htop
Upgrade & Upgrade-to
- All of the mentioned
update
commands can be applied toupgrade
. - All of the mentioned
update-to
commands can be applied toupgrade-to
. - Except that the
update
is safer thanupgrade
, sinceupdate
doesn’t remove the obsolete packages. (in case of anything goes wrong with the update/upgrade process).
Remove
Remove vim-enhanced
package and its dependencies:
[root@centos ~]# yum remove vim-enhanced
Same as:
yum erase vim-enhanced
.Remove multiple packages:
[root@centos ~]# yum remove htop tmux
Same as:
yum erase htop tmux
.Remove repository's packages
Remove all packages in epel
repository:
[root@centos ~]# yum repo-pkgs epel remove
Same as:
yum repository-packages epel remove
.Autoremove
Remove vim-enhanced
package, and remove additional unneeded packages:
[root@centos ~]# yum autoremove vim-enhanced
Remove packages that weren’t installed by user and aren’t required by anything. (Orphans):
[root@centos ~]# yum autoremove
Groupremove
Remove all packages in Security Tools
group:
[root@centos ~]# yum groupremove "Security Tools"
Same as:
Same as:
yum group remove "Security Tools"
.Same as:
yum remove "@Security Tools"
.LVM Snapshots
List snapshots:
[root@centos ~]# yum fssnapshot list
Same as:
yum fssnap list
.Snapshot summary:
[root@centos ~]# yum fssnapshot summary
Check the available space before taking a snapshot:
[root@centos ~]# yum fssnapshot have-space
Create a YUM
snapshot:
[root@centos ~]# yum fssnapshot create
Remove a YUM
snapshot:
[root@centos ~]# yum fssnapshot remove centos/root_yum_20200711
Filesystem filters
List the current used filters:
[root@centos ~]# yum fs filters
Allow only English language:
[root@centos ~]# yum fs filter languages en
Allow only English & Spanish languages:
[root@centos ~]# yum fs filter languages en:es
Allow all languages:
[root@centos ~]# yum fs filter languages all
Don’t install package’s documentations:
[root@centos ~]# yum fs filter documentation
Allow install of package’s documentation:
[root@centos ~]# yum fs filter nodocumentation
Apply current filters to a package:
[root@centos ~]# yum fs refilter htop
Apply filter clean-up to a package:
[root@centos ~]# yum fs refilter-cleanup htop
Display disk usage of packages in /usr/bin
:
[root@centos ~]# yum fs du /usr/bin
Check
Check the local RPM
database for problems:
[root@centos ~]# yum check
History
List all yum
install, update and remove actions:
[root@centos ~]# yum history list
Show details of yum
transaction 2:
[root@centos ~]# yum history info 2
Undo the yum
action from transaction 3:
[root@centos ~]# yum history undo 3
Redo the undone yum
action from transaction 4:
[root@centos ~]# yum history redo 4
Clean
Delete time records of metadata & mirror lists:
[root@centos ~]# yum clean expire-cache
Delete packages saved in cache:
[root@centos ~]# yum clean packages
Delete the cached metadata:
[root@centos ~]# yum clean metadata
Delete the sqlite database cache:
[root@centos ~]# yum clean dbcache
Delete all cache data from RPM
database:
[root@centos ~]# yum clean rpmdb
Delete all plugins cached data:
[root@centos ~]# yum clean plugins
Clean everything in cache:
[root@centos ~]# yum clean all
Some options that can be used with YUM
command:
-y
,--assumeyes
: Assume yes to all prompt questions.--assumeno
: Assume no to all prompt questions.-q
,--quiet
: Suppress the output.-v
,--verbose
: Produce extra output.--noplugins
: Run command without loading anyYUM
plugins.--enableplugin=
: Enable a particular plugin for a singleYUM
command. (e.g:yum --enableplugin=ps ps
).--disableplugin=
: Disable a particular plugin for a singleYUM
command. (e.g:yum --disableplugin=fastestmirror info htop
).--enablerepo=
: Enable currently disabled repository for a singleYUM
command. (e.g:yum --enablerepo=docker install docker
).--disablerepo=
: Disable currently enabled repository for a singleYUM
command. (e.g:yum --disablerepo=epel list available
).--downloadonly
: Download to/var/cache/yum/ARCH/PROD/REPO/PKG
without installing it. (e.g:yum --downloadonly install tmux
).--downloaddir=
: Specifies an alternate directory to store packages.--changelog
: Display changelog information of a package.