• 售前

  • 售后

热门帖子
入门百科

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

[复制链接]
何幕之之rl 显示全部楼层 发表于 2022-1-12 15:09:31 |阅读模式 打印 上一主题 下一主题
概述

yum命令安装软件包时会自动依赖包,但yum remove子命令只卸载该软件包而不能卸载依赖。
如果需要删除安装时自动安装的依赖包,则可以使用yum history子命令回滚安装事务以达到目的。
具体操作

查看yum操作(事务)历史

  1. [root@localhost ~]# yum history list 或 yum history
  2. Loading "fastestmirror" plugin
  3. Config time: 0.007
  4. Yum version: 3.4.3
  5. ID     | Login user               | Date and time    | Action(s)      | Altered
  6. -------------------------------------------------------------------------------
  7.      3 | root <root>              | 2022-01-10 15:38 | Install        |   12 EE
  8.      2 | root <root>              | 2022-01-10 10:38 | I, U           |    8   
  9.      1 | System <unset>           | 2022-01-10 10:05 | Install        |  311   
复制代码
查看某个事务详细信息

历史记录当中没有直接列出事务的详细信息,但是可根据时间和操作类型初步筛选事务。
然后通过 yum history info子命令查看事务的详细信息。
例如这里查看ID为3的事务的详细信息。
  1. [root@localhost ~]# yum history info 3
  2. Loaded plugins: fastestmirror
  3. Transaction ID : 3
  4. Begin time     : Mon Jan 10 15:38:41 2022
  5. Begin rpmdb    : 318:0a512f196782814fe726bc61f44b5332aac74b38
  6. End time       :            15:38:44 2022 (3 seconds)
  7. End rpmdb      : 330:d9fb4e7bea655b40bcabffd6eb2a8a2f81110793
  8. User           : root <root>
  9. Return-Code    : Success
  10. Command Line   : install zabbix-server-mysql zabbix-agent
  11. Transaction performed with:
  12.     Installed     rpm-4.11.3-32.el7.x86_64                      @anaconda
  13.     Installed     yum-3.4.3-158.el7.centos.noarch               @anaconda
  14.     Installed     yum-plugin-fastestmirror-1.1.31-45.el7.noarch @anaconda
  15. Packages Altered:
  16.     Dep-Install OpenIPMI-libs-2.0.23-2.el7.x86_64          @centos7
  17.     Dep-Install OpenIPMI-modalias-2.0.23-2.el7.x86_64      @centos7
  18.     Dep-Install fping-3.10-4.el7.x86_64                    @epel
  19.     Dep-Install libevent-2.0.21-4.el7.x86_64               @centos7
  20.     Dep-Install net-snmp-libs-1:5.7.2-32.el7.x86_64        @centos7
  21.     Dep-Install traceroute-3:2.0.22-2.el7.x86_64           @centos7
  22.     Dep-Install unixODBC-2.3.1-11.el7.x86_64               @centos7
  23.     Dep-Install zabbix50-5.0.18-1.el7.x86_64               @epel
  24.     Install     zabbix50-agent-5.0.18-1.el7.x86_64         @epel
  25.     Dep-Install zabbix50-dbfiles-mysql-5.0.18-1.el7.noarch @epel
  26.     Dep-Install zabbix50-server-5.0.18-1.el7.noarch        @epel
  27.     Install     zabbix50-server-mysql-5.0.18-1.el7.x86_64  @epel
  28. Scriptlet output:
  29.    1 sed: can't read /etc/sysconfig/ipmi: No such file or directory
  30. history info
复制代码
回滚事务(删除)

确定需要回滚的安装事务后,使用yum history undo子命令实现回滚。
  1. [root@localhost ~]# yum history undo 3
  2. ......
  3. Removed:
  4.   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                 
  5.   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        
  6.   zabbix50-server.noarch 0:5.0.18-1.el7         zabbix50-server-mysql.x86_64 0:5.0.18-1.el7  
复制代码
yum history子命令详细帮助

  1. [root@localhost ~]# man yum
  2. ......
  3.       history
  4.               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,
  5.               undo/redo/rollback to act on that information and new to start a new history file.
  6.               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
  7.               the transactions.
  8.               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.
  9.               Eg. "history info 1..4" will merge the first four transactions and display them as a single transaction.
  10.               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.
  11.               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"
  12.               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
  13.               install, upgrade or downgrade).  "force-remove" tells it to forcibly remove any packages that were updated or downgraded.
  14.               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
  15.               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
  16.               "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.
  17.               The addon-info command takes a transaction ID, and the packages-list command takes a package (with wildcards).
  18.               The stats command shows some statistics about the current history DB.
  19.               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
  20.               the history DB).
  21.               In "history list" you can change the behaviour of the 2nd column via the configuration option history_list_view.
  22.               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).
  23.               > - The rpmdb was changed, outside yum, after the transaction.
  24.               < - The rpmdb was changed, outside yum, before the transaction.
  25.               * - The transaction aborted before completion.
  26.               # - The transaction completed, but with a non-zero status.
  27.               E - The transaction completed fine, but had warning/error output during the transaction.
  28.               P - The transaction completed fine, but problems already existed in the rpmdb.
  29.               s - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.
复制代码
  1. [root@localhost ~]# yum history help
  2. Loaded plugins: fastestmirror
  3. 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://blog.caogenba.net/mighty13/article/details/122412447
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

帖子地址: 

回复

使用道具 举报

分享
推广
火星云矿 | 预约S19Pro,享500抵1000!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

草根技术分享(草根吧)是全球知名中文IT技术交流平台,创建于2021年,包含原创博客、精品问答、职业培训、技术社区、资源下载等产品服务,提供原创、优质、完整内容的专业IT技术开发社区。
  • 官方手机版

  • 微信公众号

  • 商务合作