I hope you are already aware of different sections of rpm field as you must be aware if your rpm is compatible with the distribution you plan to install. But anyhow if you are downloading and installing rpm from authorised repository then that should not be a problem. You can use YUM command to install the rpm, the advantage of using yum is it can help you check all the dependencies and install them without you having to worry about anything. Or you can also install an rpm using 'rpm
' tool. Now 'rpm
' tool is not as flexible as yum
but it will serve some minimal purpose.
Let me show you some scenarios with examples to install old rpm or downgrading an rpm to specific version using rpm and yum.
These steps are validated on RHEL / CentOS 7 Linux setup.
Install old rpm or downgrade rpm using yum
Here it is possible that you may have the old rpm locally available on your Linux box or it is available online on some repository.
In case the old rpm to which you wish to downgrade is available locally then you can use below syntax
# yum downgrade /path/to/old/rpm
Let me show you some simple examples. On my machine I have below version of bash
installed
# rpm -qa | grep bash bash-4.2.46-29.el7_4.x86_64
While I have an older version of bash rpm available inside /tmp. So here we are downgrading to provided specific version of rpm using yum
# ls -l /tmp/bash-4.2.46-28.el7.x86_64.rpm -r--r----- 1 deepak users 1035976 Jan 10 10:09 /tmp/bash-4.2.46-28.el7.x86_64.rpm
Now let us downgrade bash rpm using yum
# yum downgrade /tmp/bash-4.2.46-28.el7.x86_64.rpm Examining /tmp/bash-4.2.46-28.el7.x86_64.rpm: bash-4.2.46-28.el7.x86_64 Resolving Dependencies --> Running transaction check ---> Package bash.x86_64 0:4.2.46-28.el7 will be a downgrade ---> Package bash.x86_64 0:4.2.46-29.el7_4 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================= Downgrading: bash x86_64 4.2.46-28.el7 /bash-4.2.46-28.el7.x86_64 3.5 M Transaction Summary ======================================================================================================================================= Downgrade 1 Package Total size: 3.5 M Is this ok [y/d/N]: y 'Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : bash-4.2.46-28.el7.x86_64 1/2 Cleanup : bash-4.2.46-29.el7_4.x86_64 2/2 Verifying : bash-4.2.46-28.el7.x86_64 1/2 Verifying : bash-4.2.46-29.el7_4.x86_64 2/2 Removed: bash.x86_64 0:4.2.46-29.el7_4 Installed: bash.x86_64 0:4.2.46-28.el7 Complete!
yum
command will prompt for confirmation as highlighted above, to skip the prompt you can use "-y
" switch with the yum
command so the command will by default assume that you have provided confirmation for any possible question.Validate the new version of bash rpm
installed on your Linux machine
# rpm -qa | grep bash bash-4.2.46-28.el7.x86_64
So our rpm was downgraded successfully.
What if the old rpm is available on some repository?
It is possible that the rpm version you wish to downgrade is available on some custom repo or online repo. In such case you can first check which version of respective rpm you wish to downgrade.
To check the list of rpms on your repo use below command
# yum list
Now the list can be very long so you can grep for your rpm in that command
# yum list | grep bash
bash.x86_64 4.2.46-28.el7 installed
bash.x86_64 4.2.46-31.el7 rhel-7-server-rpms
bash-completion.noarch 1:2.1-6.el7 rhel-7-server-rpms
libvirt-bash-completion.x86_64 4.5.0-10.el7_6.3 rhel-7-server-rpms
pcp-pmda-bash.x86_64 4.1.0-5.el7_6 rhel-7-server-rpms
Now as you see it gave me the list of all the rpms available on my repo which matches the regex 'bash
'. Here we are interested in bash.x86_64
for which we have two versions available on the repo.
Check the installed bash rpm version
# rpm -qa | grep bash bash-4.2.46-29.el7_4.x86_64
So let us try to install old rpm version of bash
to "4.2.46-28.el7
". As you observe below I have provided the exact version and architecture of the rpm with yum
command so that yum
will not consider any other rpm to perform the downgrade.
# yum downgrade bash-4.2.46-28.el7.x86_64 Loaded plugins: product-id, search-disabled-repos, subscription-manager Resolving Dependencies --> Running transaction check ---> Package bash.x86_64 0:4.2.46-28.el7 will be a downgrade ---> Package bash.x86_64 0:4.2.46-31.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================= Downgrading: bash x86_64 4.2.46-28.el7 rhel-7-server-rpms 1.0 M Transaction Summary ======================================================================================================================================= Downgrade 1 Package Total download size: 1.0 M Is this ok [y/d/N]: y Downloading packages: bash-4.2.46-28.el7.x86_64.rpm | 1.0 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : bash-4.2.46-28.el7.x86_64 1/2 Cleanup : bash-4.2.46-31.el7.x86_64 2/2 Verifying : bash-4.2.46-28.el7.x86_64 1/2 Verifying : bash-4.2.46-31.el7.x86_64 2/2 Removed: bash.x86_64 0:4.2.46-31.el7 Installed: bash.x86_64 0:4.2.46-28.el7 Complete!
Similarly if you have a Linux with any other architecture then you must append the architecture type at the end of the rpm like i686, i386 etc
Install old rpm or downgrade rpm using rpm
Now you can also perform similar downgrade using rpm
command. If the rpm you wish to downgrade has no downgrade then using rpm
command is easier rather than yum
. The syntax to downgrade rpm is also quite easy
# rpm -Uvh /path/to/old_rpm --oldpackage
Next I will upgrade the rpm again for the sake of this article and attempt downgrade but this time with rpm
command
# rpm -Uvh /tmp/bash-4.2.46-28.el7.x86_64.rpm --oldpackage
warning: /tmp/bash-4.2.46-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:bash-4.2.46-28.el7 ################################# [ 50%]
Cleaning up / removing...
2:bash-4.2.46-29.el7_4 ################################# [100%]
--oldpackage
instead of using --force
while you are downgrading the rpm. It is also possible to downgrade an rpm using --force
but it may cause many problems in some cases.Here the switches mean
- -
h, --hash
: Print 50 hash marks as the package archive is unpacked. - -
U, --upgrade
: This upgrades or installs the package currently installed to a newer version. This is the same as install, except all other version(s) of the package are removed after the new package is installed. --oldpackage
: Allow an upgrade to replace a newer package with an older one.
Lastly I hope the steps from the article to install old rpm or downgrade rpm to specific version on Linux was helpful. So, let me know your suggestions and feedback using the comment section.