加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Yum and Rpm Daily Work Summary

发布时间:2020-12-15 18:19:42 所属栏目:安全 来源:网络整理
导读:This article used to walk you through some commonly yum and rpm usages,based on a real life scenario. ################################################################ # ? Date ? ? ? ? ? Description # ? 03/02/2019 ? ? upgrade rpm # ? 03/01/

This article used to walk you through some commonly yum and rpm usages,based on a real life scenario.

################################################################
# ? Date ? ? ? ? ? Description
# ? 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

01/19/2019

Remove or erase a installed package with its dependencies:

rpm -ev <package name>
yum erase <package name>

if it is needed,remove fail,or you can use yum erase to delete them all

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 dependencies

rpm -ev --nodeps <package name>

For example:

rpm -ev --nodpes containerd.io

Preparing packages...
containerd.io-1.2.2-3.3.el7.x86_64

02/24/2019

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.

rpm -ivh <rpm name>

For example:

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

02/25/2019

These two both work:

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

02/27/2019

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
...

03/01/2019

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

03/02/2019

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%]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读