How to use yum to list All versions of Package in Linux

This article is part of the following series.

 

The default behavior of yum is to install the most recent version of a package from the enabled repositories. However, there are situations where it may be necessary to install a particular version or revert to an earlier version of a package that is already installed.

In this post, we will show how to make yum list all available versions of a specified package and how to instruct it to install the particular one.

Show All Versions of Package with yum

Run the following command to show all versions of a package, available in enabled repositories:

$yum list <package_name> --showduplicates

Example:

# yum list glibc-locale-source --showduplicates

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:31:11 ago on Wed 20 Jul 2022 02:01:41 AM GMT.
Installed Packages
glibc-locale-source.x86_64 2.28-151.el8 @wd_rpm
Available Packages
glibc-locale-source.x86_64 2.28-151.el8 wd_rpm
glibc-locale-source.x86_64 2.28-164.el8_5.3 wd_rpm

From the output, we can see that there are 3 packages in total. One package is installed. Two packages are available to install from remote repository.

See also: Mastering the Linux Command Line — Your Complete Free Training Guide

Installed Packages: This section lists the packages that are currently installed on the system. In this case, it shows that the glibc-locale-source package with version 2.28-151.el8 is installed (@wd_rpm indicates it was installed from wd_rpm package repository).

Available Packages: This section lists the available packages that can be installed from the configured repositories. Here, it shows that there are two available versions of glibc-locale-source: version 2.28-151.el8 and version 2.28-164.el8_5.3. The wd_rpm tag indicates that these versions are available from remote package repository.

Install Specific Version Of Package with yum in Linux

To install a specific version of a package, run: $ sudo yum install <package_name><version_info>

yum install glibc-locale-source-2.28-151.el8

If you’re looking how install a package on Linux, we strongly suggest reading this article.

Force Yum To Downgrade Package

If we already have the latest version of a package installed, but we need to downgrade it to the particular version that is older, execute:

$ sudo yum downgrade <package_name>-<version_info>

understanding RPM file name

RPM package files names consist of four elements (plus the .rpm suffix): name-version- release.architecture:

Here is one example. kernel-4.18.0-425.3.1.el8.x86_64

Name : kernel
Version : 4.18.0
Release : 425.3.1.el8
Architecture : x86_64
Size : 8.8 M

Only the package name is required for installing packages from repositories. If multiple versions exist, the package with the higher version number is installed. If multiple releases of a single version exist, the package with the higher release number is installed.

Install, uninstall & upgrade packages with yum

Here are the Yum commands for installing, removing and updating packages.

CommandFunctionalityExample command
installInstall a package from yum repositoryyum install nginx
removeRemove an installed package and its dependenciesyum remove nginx
eraseSimilar to remove commandyum erase nginx
updateUpdate or or more packages on the systemyum update or sudo yum update gcc
update-toUpdate or or more packages to a specific versionyum update-to ngingx-2.7-1.1
upgradeupdate all packages to the latest versionyum upgrade
reinstallReinstall current version of a specific packageyum reinstall httpd
autoremoveRemove a package and all other unnecessary packagesyum autoremove httpd
downgradeDowngrade a specific package to an earlier versionyum downgrade nginx
swapRemove package and install anotheryum swap nginx httpd
localinstallInstall a package from a local repositoryyum localinstall package.rpm
groupinstallInstall packages from a specific groupyum groupinstall “group name”

Base Package Commands in yum

These commands will help you explore installed packages or search for packages from repositories.

CommandFunctionalityExample
listList package names from repositoriessudo yum list all
infoShow information about a specific packagesudo yum info nginx
searchSearch for a package name and descriptionsudo yum search apache
updateinfoShow information about available package updatessudo yum updateinfo baseos
check-updateShow available package updates from enabled repositoriessudo yum check-update
grouplistShow names and available package groupssudo yum grouplist
deplistShow dependencies for a specific packagesudo yum deplist vsftpd
providesLocate the package that provides a specific filesudo yum provides “*/bin/zsh”
groupinfoShow description and contents of a package groupsudo yum groupinfo “group name”
helpDisplay yum help information or help on sub commandsudo yum help or sudo yum help list

Managing Yum Repos

For adding and managing additional repositories.

CommandFunctionalityExample
repolistList the available software repositoriessudo yum repolist
repo-pkgsUse packages in a specific repositorysudo yum repo-pkgs baseos list
repoinfoShow information about enabled repositoriessudo yum repoinfo baseos
makecacheDownload repository data to cachesudo yum makecache

Troubleshooting Yum

When things go wrong with Yum, use these commands.

CommandFunctionalityExample
cleanClean out all cached package data/clean all packages metadatasudo yum clean packages or sudo yum clean all
checkCheck local RPM db for problemssudo yum check
historyView and use yum transactionssudo yum history list or sudo yum history undo or sudo yum history redo
fssnapshotShow LVM snapshotssudo yum fs filters

Helpful Options

Common options to be used with Yum commands:

Command OptionFunctionalityExample
-yAssume yes if promptedsudo yum -y install nginx
–assumenoAssume no if promptedsudo yum –assumeno install nginx
-vVerbosesudo yum -v install
-qQuietsudo yum -q install
–nopluginsDo not load any YUM pluginssudo yum –noplugins install
–disableplugin=Deactivate a specific pluginsudo yum –disableplugin=ps
–enableplugin=Activate a specific pluginsudo yum –enableplugin=ps
–changelogsShow changelog info of a packagesudo yum –changelogs install httpd
—filter=??Filter output for specific vendors, groups, architectures, and others.sudo yum list available –filter=server
–enablerepo=Enable a deactivated reposudo yum install nginx –enablerepo=??
–disablerepo=Disable an activated reposudo yum install nginx –deactivaterepo=??
–downloadonlyDownload package and no installsudo yum install –downloadonly httpd

yum Extra Commands

Some additional commands that you may need to use once a while:

CommandsFunctionality
reposyncSynchronize yum repo to local directory
show-installedShow installed packages
verifytreeCheck local repo for consistency
yumdbChange yum database
yumdownloaderDownload a package from repo to cwd
repoueryQuery remote repo and local db
repoclosureGet unmet dependency list
needs-restartingShow processes that have been updated and require restart
David Cao
David Cao

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

Articles: 275

3 Comments

  1. To list all available versions of a package, use the command:

    yum list available

    Use yum –showduplicates: To show all available versions (including older versions) of a package, run:

    yum list –showduplicates

    Search for installed versions: Use:

    yum list installed

Leave a Reply

Your email address will not be published. Required fields are marked *