This article used to walk you through some commonly yum
and rpm
usages , based on a real life scenario.node
################################################################
# 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
#
################################################################python
Yum command cheat sheetlinux
Remove or erase a installed package with its dependencies:docker
rpm -ev <package name> yum erase <package name>
if it is needed, remove fail, or you can use yum erase
to delete them allbash
rpm -ev containerd.io error: Failed dependencies: containerd.io >= 1.2.2-3 is needed by (installed) docker-ce-3:18.09.2-3.el7.x86_64
Remove or erase a installed package without checking for dependencieside
rpm -ev --nodeps <package name>
For example:ui
rpm -ev --nodpes containerd.io Preparing packages... containerd.io-1.2.2-3.3.el7.x86_64
This command will install a single rpm file if it meets all dependencies, otherwise install will fail and the output will give you the lower level rpms missed.code
rpm -ivh <rpm name>
For example:orm
rpm -ivh 416b2856f8dbb6f07a50a46018fee8596479ebc0eaeec069c26bedfa29033315-kubeadm-1.13.2-0.x86_64.rpm
warning: 416b2856f8dbb6f07a50a46018fee8596479ebc0eaeec069c26bedfa29033315-kubeadm-1.13.2-0.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 3e1ba8d5: NOKEY error: Failed dependencies: cri-tools >= 1.11.0 is needed by kubeadm-1.13.2-0.x86_64 kubectl >= 1.6.0 is needed by kubeadm-1.13.2-0.x86_64 kubelet >= 1.6.0 is needed by kubeadm-1.13.2-0.x86_64 kubernetes-cni >= 0.6.0 is needed by kubeadm-1.13.2-0.x86_64
These two both work:server
rpm -qa | grep <package name>
yum list installed | grep <package name>
For example:
rpm -qa | grep docker docker-ce-18.06.1.ce-3.el7.x86_64
yum list installed | grep docker docker-ce.x86_64 18.06.1.ce-3.el7 installed
Find packages that provide the queried file, for example:
yum provides host
32:bind-utils-9.9.4-14.el7.x86_64 : Utilities for querying DNS name servers Repo : Local-Base Matched from: Filename : /usr/bin/host ...
If you have a local rpm file, you can list its dependencies by running:
rpm -qpR <rpm name>
For example:
rpm -qpR 416b2856f8dbb6f07a50a46018fee8596479ebc0eaeec069c26bedfa29033315-kubeadm-1.13.2-0.x86_64.rpm warning: 416b2856f8dbb6f07a50a46018fee8596479ebc0eaeec069c26bedfa29033315-kubeadm-1.13.2-0.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 3e1ba8d5: NOKEY cri-tools >= 1.11.0 kubectl >= 1.6.0 kubelet >= 1.6.0 kubernetes-cni >= 0.6.0 rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(PayloadIsXz) <= 5.2-1
If you see man rpm
, there are two similar statements:
The general form of an rpm upgrade command is rpm {-U|--upgrade} [install-options] PACKAGE_FILE ... 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. rpm {-F|--freshen} [install-options] PACKAGE_FILE ... This will upgrade packages, but only ones for which an earlier version is installed.
Both rpm -Fvh
and rpm -Uvh
will perform the same task but here 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 the previously 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
:
rpm -Fvh ansible-2.7.8-1.el7.ans.noarch.rpm warning: ansible-2.7.8-1.el7.ans.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 442667a9: NOKEY Preparing... ################################# [100%] Updating / installing... 1:ansible-2.7.8-1.el7.ans ################################# [ 50%] Cleaning up / removing... 2:ansible-2.4.6.0-1.el7.ans ################################# [100%]
Remove dependencies which are not in use, any unneeded dependencies from your system, for example:
yum autoremove docker-ce
Dependencies Resolved ========================================================================================================================= Package Arch Version Repository Size ========================================================================================================================= Removing: docker-ce x86_64 18.06.1.ce-3.el7 @docker-local.repo 168 M Removing for dependencies: container-selinux noarch 2:2.68-1.el7 @Local-Extras 36 k libcgroup x86_64 0.41-20.el7 @Local-Base 134 k libseccomp x86_64 2.3.1-3.el7 @Local-Base 297 k libtool-ltdl x86_64 2.4.2-22.el7_3 @Local-Base 66 k policycoreutils-python x86_64 2.5-29.el7_6.1 @Local-Base 1.2 M Transaction Summary ========================================================================================================================= Remove 1 Package (+5 Dependent packages)
You also can add clean_requirements_on_remove=1
in /etc/yum.conf
file, then run
yum remove docker-ce
the same effect as using autoremove
.