yum彻底卸载软件包(包含依赖)

yum彻底卸载软件包(包含依赖)概述yum命令安装软件包会同时安装需要的依赖包,但yumremove却只卸载这个文件包本身,如果需要删除安装时附加的依赖包,则可以使用yumhistory的相关操作实现回滚。具体操作查看yum操作(事务)历史[root@localhost~]#yumhistorylist或yumhistoryLoading”fastestmirror”pluginConfigtime:0.007Yumversion:3.4.3ID|Loginuser

大家好,又见面了,我是你们的朋友全栈君。

概述

yum命令安装软件包时会自动依赖包,但yum remove子命令只卸载该软件包而不能卸载依赖。

如果需要删除安装时自动安装的依赖包,则可以使用yum history子命令回滚安装事务以达到目的。

具体操作

查看yum操作(事务)历史

[root@localhost ~]# yum history list 或 yum history
Loading "fastestmirror" plugin
Config time: 0.007
Yum version: 3.4.3
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     3 | root <root>              | 2022-01-10 15:38 | Install        |   12 EE
     2 | root <root>              | 2022-01-10 10:38 | I, U           |    8   
     1 | System <unset>           | 2022-01-10 10:05 | Install        |  311   

查看某个事务详细信息

历史记录当中没有直接列出事务的详细信息,但是可根据时间和操作类型初步筛选事务。

然后通过 yum history info子命令查看事务的详细信息。

例如这里查看ID为3的事务的详细信息。

[root@localhost ~]# yum history info 3
Loaded plugins: fastestmirror
Transaction ID : 3
Begin time     : Mon Jan 10 15:38:41 2022
Begin rpmdb    : 318:0a512f196782814fe726bc61f44b5332aac74b38
End time       :            15:38:44 2022 (3 seconds)
End rpmdb      : 330:d9fb4e7bea655b40bcabffd6eb2a8a2f81110793
User           : root <root>
Return-Code    : Success
Command Line   : install zabbix-server-mysql zabbix-agent
Transaction performed with:
    Installed     rpm-4.11.3-32.el7.x86_64                      @anaconda
    Installed     yum-3.4.3-158.el7.centos.noarch               @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-45.el7.noarch @anaconda
Packages Altered:
    Dep-Install OpenIPMI-libs-2.0.23-2.el7.x86_64          @centos7
    Dep-Install OpenIPMI-modalias-2.0.23-2.el7.x86_64      @centos7
    Dep-Install fping-3.10-4.el7.x86_64                    @epel
    Dep-Install libevent-2.0.21-4.el7.x86_64               @centos7
    Dep-Install net-snmp-libs-1:5.7.2-32.el7.x86_64        @centos7
    Dep-Install traceroute-3:2.0.22-2.el7.x86_64           @centos7
    Dep-Install unixODBC-2.3.1-11.el7.x86_64               @centos7
    Dep-Install zabbix50-5.0.18-1.el7.x86_64               @epel
    Install     zabbix50-agent-5.0.18-1.el7.x86_64         @epel
    Dep-Install zabbix50-dbfiles-mysql-5.0.18-1.el7.noarch @epel
    Dep-Install zabbix50-server-5.0.18-1.el7.noarch        @epel
    Install     zabbix50-server-mysql-5.0.18-1.el7.x86_64  @epel
Scriptlet output:
   1 sed: can't read /etc/sysconfig/ipmi: No such file or directory
history info

回滚事务(删除)

确定需要回滚的安装事务后,使用yum history undo子命令实现回滚。

[root@localhost ~]# yum history undo 3
......
Removed:
  OpenIPMI-libs.x86_64 0:2.0.23-2.el7           OpenIPMI-modalias.x86_64 0:2.0.23-2.el7             fping.x86_64 0:3.10-4.el7              libevent.x86_64 0:2.0.21-4.el7               net-snmp-libs.x86_64 1:5.7.2-32.el7                 
  traceroute.x86_64 3:2.0.22-2.el7              unixODBC.x86_64 0:2.3.1-11.el7                      zabbix50.x86_64 0:5.0.18-1.el7         zabbix50-agent.x86_64 0:5.0.18-1.el7         zabbix50-dbfiles-mysql.noarch 0:5.0.18-1.el7        
  zabbix50-server.noarch 0:5.0.18-1.el7         zabbix50-server-mysql.x86_64 0:5.0.18-1.el7  

yum history子命令详细帮助

[root@localhost ~]# man yum
......
      history
              The history command allows the user to view what has happened in past transactions (assuming the history_record config. option is set). You can use info/list/packages-list/packages-info/summary to view what happened,
              undo/redo/rollback to act on that information and new to start a new history file.

              The info/list/summary commands take either a transaction id or a package (with wildcards, as in Specifying package names), all three can also be passed no arguments. list can be passed the keyword "all" to  list  all
              the transactions.

              The info command can also take ranges of transaction ids, of the form start..end, which will then display a merged history as if all the transactions in the range had happened at once.
              Eg. "history info 1..4" will merge the first four transactions and display them as a single transaction.

              The packages-list/packages-info commands takes a package  (with wildcards, as in Specifying package names). And show data from the point of view of that package.

              The  undo/redo/rollback  commands  take  either a single transaction id or the keyword last and an offset from the last transaction (Eg. if you've done 250 transactions, "last" refers to transaction 250, and "last-4" refers to transaction 246). The redo command can also take some optional arguments before you specify the transaction. "force-reinstall" tells it reinstall any packages that were installed in that transaction (via install, upgrade or downgrade). "force-remove" tells it to forcibly remove any packages that were updated or downgraded. The undo/redo commands act on the specified transaction, undo'ing or repeating the work of that transaction. While the rollback command will undo all transactions up to the point of the specified transaction. For
              example, if you have 3 transactions, where package A; B and C where installed respectively.  Then "undo 1" will try to remove package A, "redo 1" will try to install package A (if it  is  not  still  installed),  and
              "rollback 1" will try to remove packages B and C. Note that after a "rollback 1" you will have a fourth transaction, although the ending rpmdb version (see: yum version) should be the same in transactions 1 and 4.

              The addon-info command takes a transaction ID, and the packages-list command takes a package (with wildcards).

              The stats command shows some statistics about the current history DB.

              The sync commands allows you to change the rpmdb/yumdb data stored for any installed packages, to whatever is in the current rpmdb/yumdb (this is mostly useful when this data was not stored when the package went into
              the history DB).

              In "history list" you can change the behaviour of the 2nd column via the configuration option history_list_view.

              In "history list" output the Altered column also gives some extra information if there was something not good with the transaction (this is also shown at the end of the package column in the packages-list command).

              > - The rpmdb was changed, outside yum, after the transaction.
              < - The rpmdb was changed, outside yum, before the transaction.
              * - The transaction aborted before completion.
              # - The transaction completed, but with a non-zero status.
              E - The transaction completed fine, but had warning/error output during the transaction.
              P - The transaction completed fine, but problems already existed in the rpmdb.
              s - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.
[root@localhost ~]# yum history help
Loaded plugins: fastestmirror
Invalid history sub-command, use: list, info, summary, repeat, redo, undo, new, rollback, addon, addon-info, stats, statistics, sync, synchronizepkg, pkgs, pkg-list, pkgs-list, package, package-list, packages, packages-list, pkg-info, pkgs-info, package-info, packages-info.
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/134327.html原文链接:https://javaforall.net

(1)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 秦九韶计算多项式的方法_秦九韶

    秦九韶计算多项式的方法_秦九韶本人水平有限,题解不到为处,请多多谅解本蒟蒻谢谢大家观看秦九韶公式:可不断的提取x作公因式,写成如上形式不断将x=4由里往外扩展,大大方便了计算

    2022年8月3日
    3
  • 虚拟机CentOS系统没有UNIX2dos或dos2UNIX命令的解决方案(参考各路大佬后的总结)

    虚拟机CentOS系统没有UNIX2dos或dos2UNIX命令的解决方案(参考各路大佬后的总结)首先申明一下,只是本人在该问题上遇到的弯路,再通过查看各路大佬的方法总结出来的解决方法:因为是看到了这篇文章https://blog.csdn.net/w616589292/article/details/38274475,然后我就走上了我的弯路了,下载了hd2u-1.0.0.tgz还有popt-1.8-1.x86_64.rpm 配置好了一切发现没有一点卵用。然后我又看见了这篇文章http:/…

    2022年5月18日
    34
  • 【转载】viewState详解

    【转载】viewState详解

    2021年11月21日
    55
  • 12864液晶并行方式显示

    12864液晶并行方式显示

    2021年12月1日
    51
  • centos7安装wget命令_centos中wget

    centos7安装wget命令_centos中wget方法一:yuminstallwget方法二:由于安装的centos是mini版,并且自带的软件源里也没有wget命令,只好自己下载了。网易源下载wget的连接下载后上传到centos上,CD到安装包的目录里,使用rpm安装。rpm-ivhwget-1.14-18.el7_6.1.x86_64.rpm安装包上传到服务器上可以用三种方法上传。centos安装…

    2022年10月10日
    3
  • 一致性哈希算法的原理与实现

    一致性哈希算法的原理与实现分布式系统中对象与节点的映射关系,传统方案是使用对象的哈希值,对节点个数取模,再映射到相应编号的节点,这种方案在节点个数变动时,绝大多数对象的映射关系会失效而需要迁移;而一致性哈希算法中,当节点个数变动时,映射关系失效的对象非常少,迁移成本也非常小。本文总结了一致性哈希的算法原理和Java实现,并列举了其应用。作者:王克锋出处:https://kefeng.wang/2018/08/1…

    2022年7月27日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号