This article is part of the following series.
- 4 ways to list files within a rpm package in Linux
- 3 ways to Check RPM package dependency in Linux
- How to use yum to list All versions of Package in Linux
- 5 ways to list installed packages in Linux
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.
Get Your Linux Course!
Join our Linux Course and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux today!Table of Contents
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.
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.
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 |
JefferyL
Wednesday 20th of November 2024
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
Vic Tru
Sunday 26th of November 2023
Amazing. It works for me. Thanks.
4 ways to list files within a rpm package in Linux - howtouselinux
Saturday 7th of October 2023
[…] How to use yum to list All versions of Package in Linux […]