How to use yum to list All versions of Package

Table of Contents

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

Install Specific Version Of Package

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

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

If you’re looking to 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.

Command Functionality Example command
install Install a package from yum repository yum install nginx
remove Remove an installed package and its dependencies yum remove nginx
erase Similar to remove command yum erase nginx
update Update or or more packages on the system yum update or sudo yum update gcc
update-to Update or or more packages to a specific version yum update-to ngingx-2.7-1.1
upgrade update all packages to the latest version yum upgrade
reinstall Reinstall current version of a specific package yum reinstall httpd
autoremove Remove a package and all other unnecessary packages yum autoremove httpd
downgrade Downgrade a specific package to an earlier version yum downgrade nginx
swap Remove package and install another yum swap nginx httpd
localinstall Install a package from a local repository yum localinstall package.rpm
groupinstall Install packages from a specific group yum groupinstall “group name”

Base Package Commands in yum

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

Command Functionality Example
list List package names from repositories sudo yum list all
info Show information about a specific package sudo yum info nginx
search Search for a package name and description sudo yum search apache
updateinfo Show information about available package updates sudo yum updateinfo baseos
check-update Show available package updates from enabled repositories sudo yum check-update
grouplist Show names and available package groups sudo yum grouplist
deplist Show dependencies for a specific package sudo yum deplist vsftpd
provides Locate the package that provides a specific file sudo yum provides “*/bin/zsh”
groupinfo Show description and contents of a package group sudo yum groupinfo “group name”
help Display yum help information or help on sub command sudo yum help or sudo yum help list

Managing Yum Repos

For adding and managing additional repositories.

Command Functionality Example
repolist List the available software repositories sudo yum repolist
repo-pkgs Use packages in a specific repository sudo yum repo-pkgs baseos list
repoinfo Show information about enabled repositories sudo yum repoinfo baseos
makecache Download repository data to cache sudo yum makecache

Troubleshooting Yum

When things go wrong with Yum, use these commands.

Command Functionality Example
clean Clean out all cached package data/clean all packages metadata sudo yum clean packages or sudo yum clean all
check Check local RPM db for problems sudo yum check
history View and use yum transactions sudo yum history list or sudo yum history undo or sudo yum history redo
fssnapshot Show LVM snapshots sudo yum fs filters

Helpful Options

Common options to be used with Yum commands:

Command Option Functionality Example
-y Assume yes if prompted sudo yum -y install nginx
–assumeno Assume no if prompted sudo yum –assumeno install nginx
-v Verbose sudo yum -v install
-q Quiet sudo yum -q install
–noplugins Do not load any YUM plugins sudo yum –noplugins install
–disableplugin= Deactivate a specific plugin sudo yum –disableplugin=ps
–enableplugin= Activate a specific plugin sudo yum –enableplugin=ps
–changelogs Show changelog info of a package sudo yum –changelogs install httpd
—filter=?? Filter output for specific vendors, groups, architectures, and others. sudo yum list available –filter=server
–enablerepo= Enable a deactivated repo sudo yum install nginx –enablerepo=??
–disablerepo= Disable an activated repo sudo yum install nginx –deactivaterepo=??
–downloadonly Download package and no install sudo yum install –downloadonly httpd

yum Extra Commands

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

Commands Functionality
reposync Synchronize yum repo to local directory
show-installed Show installed packages
verifytree Check local repo for consistency
yumdb Change yum database
yumdownloader Download a package from repo to cwd
repouery Query remote repo and local db
repoclosure Get unmet dependency list
needs-restarting Show processes that have been updated and require restart is dedicated to providing comprehensive information on using Linux.

We hope you find our site helpful and informative.

Learn More


Linux du command

Basic Usage: Syntax: du [options] [directory/file] Basic Examples: du /path/to/file: Displays disk usage of the specified file. du /path/to/directory: Shows disk usage of all the

Read More »

RHCSA Practice Exam

RHCSA Practice Exam A General Notes Here are some tips to ensure your exam starts with a clean environment: You do not need external servers

Read More »