This article used to walk you through some commonly yum
and rpm
usages , based on a real life scenario.
################################################################ # Date Description # 03/05/2019 yum autoremove # 03/02/2019 upgrade rpm # 03/01/2019 list rpm dependencies # 02/27/2019 yum provides # 02/25/2019 search rpm installed # 02/24/2019 install rpm # 01/19/2019 remove package # ################################################################
Yum command cheat sheet
rpm
command is one of the package management command.
01/19/2019
Remove or erase a installed package with its dependencies:
1 | rpm -ev <package name> |
if the rpm is part of other dependencies, rpm -ev
will fail, or you can use yum erase
to delete them all:
1 | rpm -ev containerd.io |
Remove or erase a installed package without checking for dependencies
1 | rpm -ev --nodeps <package name> |
For example:
1 | rpm -ev --nodpes containerd.io |
02/24/2019
This command will install a single rpm file if it meets all dependencies, otherwise install will fail and the output will show you the missig rpms.
1 | rpm -ivh <rpm name> |
For example:
1 | rpm -ivh 416b2856f8dbb6f07a50a46018fee8596479ebc0eaeec069c26bedfa29033315-kubeadm-1.13.2-0.x86_64.rpm |
02/25/2019
These two both work:
1 | ## query package installed |
For example:
1 | rpm -qa | grep docker |
1 | yum list installed | grep docker |
02/27/2019
Find packages that provide the queried file, for example:
1 | yum provides host |
Next you can install it:
1 | yum install -y bind-utils |
03/01/2019
If you have a local rpm file, you can list its dependencies by running:
1 | rpm -qpR <rpm name> |
For example:
1 | rpm -qpR 416b2856f8dbb6f07a50a46018fee8596479ebc0eaeec069c26bedfa29033315-kubeadm-1.13.2-0.x86_64.rpm |
03/02/2019
If you run man rpm
, there are two similar statements:
1 | The general form of an rpm upgrade command is |
Both rpm -Fvh
and rpm -Uvh
will perform the same task but the diff is rpm -Uvh
is also same as rpm -ivh
, you can use any of them I mean rpm -ivh
or rpm -Uvh
for installing the package.
But for upgrading installed package you can use any of rpm -Fvh
or rpm -Uvh
.
rpm -Fvh
is used for upgrading the existing package (installed package).
rpm -Uvh
is used for installing the package and upgrading the package both.
For example, upgrade ansible
from 2.4.6.0
to 2.7.8
:
1 | rpm -Fvh ansible-2.7.8-1.el7.ans.noarch.rpm |
03/05/2019
Remove dependencies which are not in use, any unneeded dependencies from your system, for example:
1 | yum autoremove docker-ce |
1 | Dependencies Resolved |
You also can add clean_requirements_on_remove=1
in /etc/yum.conf
file, then run
1 | yum remove docker-ce |
the same effect as using autoremove
.