As part of application requirements or testing, you might need to install specific version of a package. DNF is a package manager for RPM-based Linux distributions such Fedora, RHEL, Rocky Linux, AlmaLinux, and more.
In this tutorial, we learn how to install specific version of package using DNF.
DNF List all avaiable package versions
To list all available package versions for the current release, type:
dnf --showduplicates list
To list all available versions of a specific package, type:
dnf --showduplicates list samba
The output display in the following format:
package_name.architecture version_number–build_number repository
You can the available package versions and which version is already been installed.
Install specific version of a package using DNF
Once you find the specific version for the package to install, use the dnf command as follows:
sudo dnf install samba-4.15.7-0.fc35
This will download and install the specific samba version ( ie samba-4.15.7-0.fc35).
An alternative option to install an older package version is to use dnf downgrade command, assuming you have a newer version installed.
dnf downgrade package-name+version
This will downgrade the installed version to the older package version along with all the dependencies ( assuming the old package available in the repo).
If the package is not available in the repository, you can search and download rpm package from Koji.
dnf downgrade path/to/package.rpm
dnf install path/to/package.rpm
You need to keep remember that when you run dnf upgrade or update command the package will get updated with the new version which is available in the repository.
In this tutorial, we learned how to install specific package using the DNF package manager in RHEL based Linux distributions.