保存安装的rpm到本地

方法一:

[root@ServerA ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
#修改keepcache=1即可在yum安装时保存rpm包
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/
bug_report_page.php?category=yum
distroverpkg=centos-release       

对于centos7来说可以在通过ls /var/cache/yum/x86_64/7/查看所有下载记录

方法二(推荐):

yum install -y 包名 -–downloadonly

yum install -y 包名 -–downloadonly -–downloaddir=路径

yum reinstall -y 包名 -–downloadonly -–downloaddir=路径

yum卸载软件包包括依赖

适用场合:当我们安装的软件包包含较多依赖,想要完全卸载相应的软件包及依赖

  1. 通过yum history list列出yum安装/卸载历史 注意ID编号
[root@ServerB ~]# yum history list
Loaded plugins: fastestmirror, langpacks
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    30 | install -y samba*        | 2019-12-03 18:45 | I, U           |   47
    29 | history undo 24          | 2019-12-03 17:39 | Install        |   13
    28 | history undo 27          | 2019-12-03 17:38 | Erase          |    1
    27 | install -y bind-utils –d | 2019-12-03 17:32 | Install        |    1
    26 | remove -y bind-utils     | 2019-12-03 17:31 | Erase          |    5   
  1. 使用yum history undo ID即可连通依赖进行卸载
[root@ServerB ~]#
[root@ServerB ~]# yum history undo 30
Loaded plugins: fastestmirror, langpacks
Undoing transaction 30, from Tue Dec  3 18:45:26 2019
    Updated     dbus-1:1.6.12-13.el7.x86_64                     @anaconda
    Update           1:1.10.24-13.el7_6.x86_64                  @base
    Updated     dbus-libs-1:1.6.12-13.el7.x86_64                @anaconda
    Update                1:1.10.24-13.el7_6.x86_64             @base
    Updated     dbus-x11-1:1.6.12-13.el7.x86_64                 @anaconda
    Update               1:1.10.24-13.el7_6.x86_64              @base
    Updated     glusterfs-3.7.1-16.el7.x86_64                   @anaconda
    Update                3.12.2-47.2.el7.x86_64                @base
    Updated     glusterfs-api-3.7.1-16.el7.x86_64               @anaconda
    Update                    3.12.2-47.2.el7.x86_64            @base
    Updated     glusterfs-client-xlators-3.7.1-16.el7.x86_64    @anaconda
    Update                               3.12.2-47.2.el7.x86_64 @base
    Updated     glusterfs-fuse-3.7.1-16.el7.x86_64              @anaconda

    ...
    ...

---> Package pyldb.x86_64 0:1.4.2-1.el7 will be erased
---> Package python-tdb.x86_64 0:1.3.16-1.el7 will be erased
---> Package python-tevent.x86_64 0:0.9.37-1.el7 will be erased
---> Package samba.x86_64 0:4.9.1-6.el7 will be erased
---> Package samba-dc.x86_64 0:4.9.1-6.el7 will be erased
---> Package samba-dc-libs.x86_64 0:4.9.1-6.el7 will be erased
---> Package samba-devel.x86_64 0:4.9.1-6.el7 will be erased
---> Package samba-krb5-printing.x86_64 0:4.9.1-6.el7 will be erased
---> Package samba-pidl.noarch 0:4.9.1-6.el7 will be erased
---> Package samba-python.x86_64 0:4.9.1-6.el7 will be erased
---> Package samba-python-test.x86_64 0:4.9.1-6.el7 will be erased
---> Package samba-test.x86_64 0:4.9.1-6.el7 will be erased

    ...
    ...

 glusterfs-libs                   x86_64       3.7.1-16.el7               -              0.0
 glusterfs-api                    x86_64       3.7.1-16.el7               -              0.0
 samba-common                     noarch       4.2.3-10.el7               -              0.0
 libwbclient                      x86_64       4.2.3-10.el7               -              0.0
 samba-common-tools               x86_64       4.2.3-10.el7               -              0.0
 samba-libs                       x86_64       4.2.3-10.el7               -              0.0

Transaction Summary
===============================================================================================
Remove         22 Packages (+1 Dependent package)
Not available  25 Packages

Installed size: 33 M
Is this ok [y/N]: 

键入y即可卸载

12-28 20:30