Linux功能-使用YUM管理软件包

Posted 北海悟空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux功能-使用YUM管理软件包相关的知识,希望对你有一定的参考价值。

 一、概念

YUM,全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。

二、实例

1. 使用yum 命令显示所有软件存储库信息

[[email protected] ~]# yum repolist
Loaded plugins: langpacks
Packages                                                                                   | 4.1 kB  00:00:00     
repo id                                               repo name                                             status
Packages                                              Packages                                              4,305
repolist: 4,305

2. 用 yum 命令,安装/rhel7/dvd/Packages/bind-9.9.4-14.el7.x86_64.rpm 

[[email protected] ~]# yum localinstall /rhel7/dvd/Packages/bind-9.9.4-14.el7.x86_64.rpm 
Loaded plugins: langpacks
Examining /rhel7/dvd/Packages/bind-9.9.4-14.el7.x86_64.rpm: 32:bind-9.9.4-14.el7.x86_64
Marking /rhel7/dvd/Packages/bind-9.9.4-14.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.9.4-14.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
 Package           Arch                Version                       Repository                              Size
==================================================================================================================
Installing:
 bind              x86_64              32:9.9.4-14.el7               /bind-9.9.4-14.el7.x86_64              4.3 M

Transaction Summary
==================================================================================================================
Install  1 Package

Total size: 4.3 M
Installed size: 4.3 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 32:bind-9.9.4-14.el7.x86_64                                                                    1/1 
  Verifying  : 32:bind-9.9.4-14.el7.x86_64                                                                    1/1 

Installed:
  bind.x86_64 32:9.9.4-14.el7                                                                                     

Complete!

3. 用yum list命令找出“bind”这个软件包,观察描述信息,@/bind-9.9.4-14.el7.x86_64”,表示已被安装上了 

即包名称前存在符号“@”为已安装

[[email protected] ~]# yum list bind
Loaded plugins: langpacks
Installed Packages
bind.x86_64                               32:9.9.4-14.el7                               @/bind-9.9.4-14.el7.x86_64

4. 用yum list命令找出“tftp-server”这个软件包,观察描述信息是Package,包前没有@符号,表示未安装

[[email protected] ~]# yum list tftp-server
Loaded plugins: langpacks
Available Packages
tftp-server.x86_64                                       5.2-11.el7                                       Packages

5. 用 yum 命令安装 tftp-server 这个软件包,有任何交互提问,直接回答 yes 

[[email protected] ~]# yum -y install tftp-server
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package tftp-server.x86_64 0:5.2-11.el7 will be installed
--> Processing Dependency: xinetd for package: tftp-server-5.2-11.el7.x86_64
--> Running transaction check
---> Package xinetd.x86_64 2:2.3.15-12.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
 Package                    Arch                  Version                           Repository               Size
==================================================================================================================
Installing:
 tftp-server                x86_64                5.2-11.el7                        Packages                 44 k
Installing for dependencies:
 xinetd                     x86_64                2:2.3.15-12.el7                   Packages                128 k

Transaction Summary
==================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 172 k
Installed size: 325 k
Downloading packages:
(1/2): tftp-server-5.2-11.el7.x86_64.rpm                                                   |  44 kB  00:00:00     
(2/2): xinetd-2.3.15-12.el7.x86_64.rpm                                                     | 128 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------
Total                                                                             772 kB/s | 172 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:xinetd-2.3.15-12.el7.x86_64                                                                  1/2 
  Installing : tftp-server-5.2-11.el7.x86_64                                                                  2/2 
  Verifying  : 2:xinetd-2.3.15-12.el7.x86_64                                                                  1/2 
  Verifying  : tftp-server-5.2-11.el7.x86_64                                                                  2/2 

Installed:
  tftp-server.x86_64 0:5.2-11.el7                                                                                 

Dependency Installed:
  xinetd.x86_64 2:2.3.15-12.el7                                                                                   

Complete!
[[email protected] ~]# 

6. 再次查看“tftp-server”这个软件包的安装情况,Package前已存在@符号

[[email protected] ~]# yum list tftp-server
Loaded plugins: langpacks
Installed Packages
tftp-server.x86_64                                      5.2-11.el7                                       @Packages
[[email protected] ~]# 

7. 检查所有以安装的软件包,可以看到几乎所有都是@anaconda(安装系统时就安装了) 

[[email protected] ~]# yum list installed
Loaded plugins: langpacks
Installed Packages
GConf2.x86_64                                         3.2.6-8.el7                          @anaconda/7.0          
ModemManager.x86_64                                   1.1.0-6.git20130913.el7              @anaconda/7.0          
ModemManager-glib.x86_64                              1.1.0-6.git20130913.el7              @anaconda/7.0          
NetworkManager.x86_64                                 1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda/7.0          
NetworkManager-config-server.x86_64                   1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda/7.0          
NetworkManager-glib.x86_64                            1:0.9.9.1-13.git20140326.4dba720.el7 @anaconda/7.0      
...

8.  显示所有未安装的软件包,Packages前无@符号

[[email protected] ~]# yum list available
Loaded plugins: langpacks
Available Packages
389-ds-base.x86_64                                           1.3.1.6-25.el7                               Packages
389-ds-base-libs.x86_64                                      1.3.1.6-25.el7                               Packages
ElectricFence.i686                                           2.2.2-39.el7                                 Packages
ElectricFence.x86_64                                         2.2.2-39.el7                                 Packages
GConf2.i686                                                  3.2.6-8.el7                                  Packages
GeoIP.i686                                                   1.5.0-9.el7                                  Packages
GeoIP.x86_64                                                 1.5.0-9.el7                                  Packages

9. 用 yum search 命令,找出所有名称或描述信息中,含有 SSH 字符串的软件包 

   search  :搜寻某个软件名称或者是描述 (description) 的重要关键字

[[email protected] ~]# yum search SSH
Loaded plugins: langpacks
================================================ N/S matched: SSH ================================================
ksshaskpass.x86_64 : A KDE version of ssh-askpass with KWallet support
libssh2.i686 : A library implementing the SSH2 protocol
libssh2.x86_64 : A library implementing the SSH2 protocol
openssh.x86_64 : An open source implementation of SSH protocol versions 1 and 2
openssh-askpass.x86_64 : A passphrase dialog for OpenSSH and X
openssh-clients.x86_64 : An open source SSH client applications
openssh-keycat.x86_64 : A mls keycat backend for openssh
openssh-server.x86_64 : An open source SSH server daemon

  Name and summary matches only, use "search all" for everything.

  [[email protected] ~]# yum search tftp
  Loaded plugins: langpacks
  =============================================== N/S matched: tftp ================================================
  tftp.x86_64 : The client for the Trivial File Transfer Protocol (TFTP)
  tftp-server.x86_64 : The server for the Trivial File Transfer Protocol (TFTP)

  Name and summary matches only, use "search all" for everything.

10. 用 yum list 命令,找出名称中有“ssh”的字符串的软件软件包 

   list    :列出目前 yum 所管理的所有的软件名称与版本,有点类似 rpm -qa;

[[email protected] ~]# yum list *ssh*
Loaded plugins: langpacks
Installed Packages
libssh2.x86_64                                          1.4.3-8.el7                                  @anaconda/7.0
openssh.x86_64                                          6.4p1-8.el7                                  @anaconda/7.0
openssh-clients.x86_64                                  6.4p1-8.el7                                  @anaconda/7.0
openssh-server.x86_64                                   6.4p1-8.el7                                  @anaconda/7.0
Available Packages
ksshaskpass.x86_64                                      0.5.3-7.el7                                  Packages     
libssh2.i686                                            1.4.3-8.el7                                  Packages     
openssh-askpass.x86_64                                  6.4p1-8.el7                                  Packages     
openssh-keycat.x86_64                                   6.4p1-8.el7                                  Packages     

11. 用 yum 命令,显示/etc/named.conf 这个文件是哪个软件包提供的 

[[email protected] ~]# yum provides /etc/named.conf 
Loaded plugins: langpacks
32:bind-9.9.4-14.el7.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server
Repo        : Packages
Matched from:
Filename    : /etc/named.conf

32:bind-9.9.4-14.el7.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server
Repo        : @/bind-9.9.4-14.el7.x86_64
Matched from:
Filename    : /etc/named.conf

[[email protected] ~]# 

12. 使用yum卸载bind软件包

[[email protected] ~]# yum remove bind
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.9.4-14.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
 Package           Arch                Version                      Repository                               Size
==================================================================================================================
Removing:
 bind              x86_64              32:9.9.4-14.el7              @/bind-9.9.4-14.el7.x86_64              4.3 M

Transaction Summary
==================================================================================================================
Remove  1 Package

Installed size: 4.3 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 32:bind-9.9.4-14.el7.x86_64                                                                    1/1 
  Verifying  : 32:bind-9.9.4-14.el7.x86_64                                                                    1/1 

Removed:
  bind.x86_64 32:9.9.4-14.el7                                                                                     

Complete!
[[email protected] ~]# 

13. 用 yum 命令,检查所有可以用的软件组(包括被隐藏的也显示出来) 

[[email protected] ~]# yum group list hidden
Loaded plugins: langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Available environment groups:
   Minimal Install
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
Available Groups:
   Additional Development
   Anaconda Tools
   Backup Client
   Backup Server
   Base
   Compatibility Libraries
   Conflicts (Server)
   Console Internet Tools
   Core
   DNS Name Server
   Debugging Tools
   Desktop Debugging and Performance Tools
   Development Tools
   Dial-up Networking Support
   Directory Client
   Directory Server
   E-mail Server
   Emacs
   FTP Server
   File and Storage Server
   Fonts
   GNOME
   Graphical Administration Tools
   Graphics Creation Tools
   Guest Agents
   Guest Desktop Agents
   Hardware Monitoring Utilities
   Identity Management Server
   Infiniband Support
   Input Methods
   Internet Browser
   Java Platform
   KDE
   Large Systems Performance
   Legacy UNIX Compatibility
   Legacy X Window System Compatibility
   Load Balancer
   Mainframe Access
   MariaDB Database Client
   MariaDB Database Server
   Multimedia
   Network File System Client
   Network Infrastructure Server
   Networking Tools
   php Support
   Performance Tools
   Perl Support
   Perl for Web
   Platform Development
   PostgreSQL Database Client
   PostgreSQL Database Server
   Print Server
   Printing Client
   Python
   Remote Desktop Clients
   Remote Management for Linux
   Ruby Support
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
   Technical Writing
   Virtualization Client
   Virtualization Hypervisor
   Virtualization Platform
   Virtualization Tools
   Web Server
   Web Servlet Engine
   X Window System
Done
[[email protected] ~]# 

14. 检查组“Web Server”包含的信息 

[[email protected] ~]# yum group info "Web Server"
Loaded plugins: langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)

Group: Web Server
 Group-Id: web-server
 Description: Allows the system to act as a web server, and run Perl and Python web applications.
 Mandatory Packages:
   +httpd
 Default Packages:
   +crypto-utils
   +httpd-manual
   +mod_fcgid
   +mod_ssl
 Optional Packages:
   certmonger
   libmemcached
   memcached
   mod_auth_kerb
   mod_nss
   mod_revocator
   mod_security
   mod_security_crs
   perl-CGI
   perl-CGI-Session
   python-memcached
   squid
[[email protected] ~]# 

15. 用 yum 命令,安装软件组“Web Server” 

[[email protected] ~]# yum group install "Web Server"
Loaded plugins: langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Resolving Dependencies
--> Running transaction check
---> Package crypto-utils.x86_64 0:2.4.1-42.el7 will be installed
--> Processing Dependency: perl(Newt) for package: crypto-utils-2.4.1-42.el7.x86_64
---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-17.el7 for package: httpd-2.4.6-17.el7.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-17.el7.x86_64
---> Package httpd-manual.noarch 0:2.4.6-17.el7 will be installed
---> Package mod_fcgid.x86_64 0:2.3.9-4.el7 will be installed
---> Package mod_ssl.x86_64 1:2.4.6-17.el7 will be installed
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be installed
---> Package perl-Newt.x86_64 0:1.08-36.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
 Package                     Arch                  Version                          Repository               Size
==================================================================================================================
Installing for group install "Web Server":
 crypto-utils                x86_64                2.4.1-42.el7                     Packages                 78 k
 httpd                       x86_64                2.4.6-17.el7                     Packages                1.2 M
 httpd-manual                noarch                2.4.6-17.el7                     Packages                1.3 M
 mod_fcgid                   x86_64                2.3.9-4.el7                      Packages                 79 k
 mod_ssl                     x86_64                1:2.4.6-17.el7                   Packages                 97 k
Installing for dependencies:
 apr                         x86_64                1.4.8-3.el7                      Packages                103 k
 apr-util                    x86_64                1.5.2-6.el7                      Packages                 92 k
 httpd-tools                 x86_64                2.4.6-17.el7                     Packages                 77 k
 perl-Newt                   x86_64                1.08-36.el7                      Packages                 64 k

Transaction Summary
==================================================================================================================
Install  5 Packages (+4 Dependent packages)

Total download size: 3.1 M
Installed size: 10 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): apr-1.4.8-3.el7.x86_64.rpm                                                          | 103 kB  00:00:00     
(2/9): crypto-utils-2.4.1-42.el7.x86_64.rpm                                                |  78 kB  00:00:00     
(3/9): apr-util-1.5.2-6.el7.x86_64.rpm                                                     |  92 kB  00:00:00     
(4/9): httpd-2.4.6-17.el7.x86_64.rpm                                                       | 1.2 MB  00:00:00     
(5/9): httpd-tools-2.4.6-17.el7.x86_64.rpm                                                 |  77 kB  00:00:00     
(6/9): mod_fcgid-2.3.9-4.el7.x86_64.rpm                                                    |  79 kB  00:00:00     
(7/9): mod_ssl-2.4.6-17.el7.x86_64.rpm                                                     |  97 kB  00:00:00     
(8/9): perl-Newt-1.08-36.el7.x86_64.rpm                                                    |  64 kB  00:00:00     
(9/9): httpd-manual-2.4.6-17.el7.noarch.rpm                                                | 1.3 MB  00:00:00     
------------------------------------------------------------------------------------------------------------------
Total                                                                             7.0 MB/s | 3.1 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                                                         1/9 
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                    2/9 
  Installing : httpd-tools-2.4.6-17.el7.x86_64                                                                3/9 
  Installing : httpd-2.4.6-17.el7.x86_64                                                                      4/9 
  Installing : perl-Newt-1.08-36.el7.x86_64                                                                   5/9 
  Installing : crypto-utils-2.4.1-42.el7.x86_64                                                               6/9 
  Installing : mod_fcgid-2.3.9-4.el7.x86_64                                                                   7/9 
  Installing : httpd-manual-2.4.6-17.el7.noarch                                                               8/9 
  Installing : 1:mod_ssl-2.4.6-17.el7.x86_64                                                                  9/9 
  Verifying  : mod_fcgid-2.3.9-4.el7.x86_64                                                                   1/9 
  Verifying  : httpd-manual-2.4.6-17.el7.noarch                                                               2/9 
  Verifying  : perl-Newt-1.08-36.el7.x86_64                                                                   3/9 
  Verifying  : 1:mod_ssl-2.4.6-17.el7.x86_64                                                                  4/9 
  Verifying  : httpd-2.4.6-17.el7.x86_64                                                                      5/9 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                    6/9 
  Verifying  : httpd-tools-2.4.6-17.el7.x86_64                                                                7/9 
  Verifying  : apr-1.4.8-3.el7.x86_64                                                                         8/9 
  Verifying  : crypto-utils-2.4.1-42.el7.x86_64                                                               9/9 

Installed:
  crypto-utils.x86_64 0:2.4.1-42.el7     httpd.x86_64 0:2.4.6-17.el7       httpd-manual.noarch 0:2.4.6-17.el7    
  mod_fcgid.x86_64 0:2.3.9-4.el7         mod_ssl.x86_64 1:2.4.6-17.el7    

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7             apr-util.x86_64 0:1.5.2-6.el7       httpd-tools.x86_64 0:2.4.6-17.el7      
  perl-Newt.x86_64 0:1.08-36.el7      

Complete!
[[email protected] ~]# 

16. 检查“Web Server”的信息,强制安装和默认安装的包都标记为已安装“=” 

[[email protected] ~]# yum group info "Web Server"
Loaded plugins: langpacks

Group: Web Server
 Group-Id: web-server
 Description: Allows the system to act as a web server, and run Perl and Python web applications.
 Mandatory Packages:
   =httpd
 Default Packages:
   =crypto-utils
   =httpd-manual
   =mod_fcgid
   =mod_ssl
 Optional Packages:
   certmonger
   libmemcached
   memcached
   mod_auth_kerb
   mod_nss
   mod_revocator
   mod_security
   mod_security_crs
   perl-CGI
   perl-CGI-Session
   python-memcached
   squid
[[email protected] ~]# 

17. 卸载软件组“Web Server”,并确认卸载成功 

[[email protected] ~]# yum group remove "Web Server"
Loaded plugins: langpacks
No environment named Web Server exists
Resolving Dependencies
--> Running transaction check
---> Package crypto-utils.x86_64 0:2.4.1-42.el7 will be erased
---> Package httpd.x86_64 0:2.4.6-17.el7 will be erased
---> Package httpd-manual.noarch 0:2.4.6-17.el7 will be erased
---> Package mod_fcgid.x86_64 0:2.3.9-4.el7 will be erased
---> Package mod_ssl.x86_64 1:2.4.6-17.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
 Package                     Arch                  Version                         Repository                Size
==================================================================================================================
Removing:
 crypto-utils                x86_64                2.4.1-42.el7                    @Packages                179 k
 httpd                       x86_64                2.4.6-17.el7                    @Packages                3.7 M
 httpd-manual                noarch                2.4.6-17.el7                    @Packages                5.5 M
 mod_fcgid                   x86_64                2.3.9-4.el7                     @Packages                228 k
 mod_ssl                     x86_64                1:2.4.6-17.el7                  @Packages                219 k

Transaction Summary
==================================================================================================================
Remove  5 Packages

Installed size: 9.7 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:mod_ssl-2.4.6-17.el7.x86_64                                                                  1/5 
  Erasing    : httpd-manual-2.4.6-17.el7.noarch                                                               2/5 
  Erasing    : mod_fcgid-2.3.9-4.el7.x86_64                                                                   3/5 
  Erasing    : httpd-2.4.6-17.el7.x86_64                                                                      4/5 
  Erasing    : crypto-utils-2.4.1-42.el7.x86_64                                                               5/5 
  Verifying  : crypto-utils-2.4.1-42.el7.x86_64                                                               1/5 
  Verifying  : mod_fcgid-2.3.9-4.el7.x86_64                                                                   2/5 
  Verifying  : httpd-manual-2.4.6-17.el7.noarch                                                               3/5 
  Verifying  : 1:mod_ssl-2.4.6-17.el7.x86_64                                                                  4/5 
  Verifying  : httpd-2.4.6-17.el7.x86_64                                                                      5/5 

Removed:
  crypto-utils.x86_64 0:2.4.1-42.el7     httpd.x86_64 0:2.4.6-17.el7       httpd-manual.noarch 0:2.4.6-17.el7    
  mod_fcgid.x86_64 0:2.3.9-4.el7         mod_ssl.x86_64 1:2.4.6-17.el7    

Complete!
[[email protected] ~]# yum group info "Web Server"
Loaded plugins: langpacks

Group: Web Server
 Group-Id: web-server
 Description: Allows the system to act as a web server, and run Perl and Python web applications.
 Mandatory Packages:
   +httpd
 Default Packages:
   +crypto-utils
   +httpd-manual
   +mod_fcgid
   +mod_ssl
 Optional Packages:
   certmonger
   libmemcached
   memcached
   mod_auth_kerb
   mod_nss
   mod_revocator
   mod_security
   mod_security_crs
   perl-CGI
   perl-CGI-Session
   python-memcached
   squid
[[email protected] ~]# 

18. 用 tail 命令,观察 yum 的日志文件,前面的安装和移除操作都被记录在日志文件中  

[[email protected] ~]# grep "log" /etc/yum.conf         #yum 的配置文件定义了日志的位置
logfile=/var/log/yum.log
[[email protected] ~]# tail -n 20 /var/log/yum.log 
Nov 02 14:35:12 Installed: 32:bind-9.9.4-14.el7.x86_64
Nov 02 14:40:07 Installed: 2:xinetd-2.3.15-12.el7.x86_64
Nov 02 14:40:07 Installed: tftp-server-5.2-11.el7.x86_64
Nov 02 15:20:15 Erased: 32:bind-9.9.4-14.el7.x86_64
Nov 02 15:51:21 Installed: apr-1.4.8-3.el7.x86_64
Nov 02 15:51:21 Installed: apr-util-1.5.2-6.el7.x86_64
Nov 02 15:51:21 Installed: httpd-tools-2.4.6-17.el7.x86_64
Nov 02 15:51:23 Installed: httpd-2.4.6-17.el7.x86_64
Nov 02 15:51:23 Installed: perl-Newt-1.08-36.el7.x86_64
Nov 02 15:51:23 Installed: crypto-utils-2.4.1-42.el7.x86_64
Nov 02 15:51:23 Installed: mod_fcgid-2.3.9-4.el7.x86_64
Nov 02 15:51:24 Installed: httpd-manual-2.4.6-17.el7.noarch
Nov 02 15:51:25 Installed: 1:mod_ssl-2.4.6-17.el7.x86_64
Nov 02 16:26:49 Erased: 1:mod_ssl-2.4.6-17.el7.x86_64
Nov 02 16:26:49 Erased: httpd-manual-2.4.6-17.el7.noarch
Nov 02 16:26:49 Erased: mod_fcgid-2.3.9-4.el7.x86_64
Nov 02 16:26:49 Erased: httpd-2.4.6-17.el7.x86_64
Nov 02 16:26:50 Erased: crypto-utils-2.4.1-42.el7.x86_64
[[email protected] ~]# 

19. 使用yum history检查之前的yum操作结果


[[email protected] ~]# yum history
Loaded plugins: langpacks
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     6 | root <root>              | 2016-11-02 16:26 | Erase          |    5   
     5 | root <root>              | 2016-11-02 15:51 | Install        |    9   
     4 | root <root>              | 2016-11-02 15:20 | Erase          |    1   
     3 | root <root>              | 2016-11-02 14:40 | Install        |    2   
     2 | root <root>              | 2016-11-02 14:35 | Install        |    1   
     1 | System <unset>           | 2016-09-27 20:12 | Install        | 1236   
history list

20. 执行最近一次 yum 操作的反操作(最近一次是删除 Web Server,所有反操作就是安装 Web Server 组,序号6则是步骤19中的ID6) 

[[email protected] ~]# yum history undo 6
Loaded plugins: langpacks
Undoing transaction 6, from Wed Nov  2 16:26:49 2016
    Erase crypto-utils-2.4.1-42.el7.x86_64 @Packages
    Erase httpd-2.4.6-17.el7.x86_64        @Packages
    Erase httpd-manual-2.4.6-17.el7.noarch @Packages
    Erase mod_fcgid-2.3.9-4.el7.x86_64     @Packages
    Erase mod_ssl-1:2.4.6-17.el7.x86_64    @Packages
Resolving Dependencies
--> Running transaction check
---> Package crypto-utils.x86_64 0:2.4.1-42.el7 will be installed
---> Package httpd.x86_64 0:2.4.6-17.el7 will be installed
---> Package httpd-manual.noarch 0:2.4.6-17.el7 will be installed
---> Package mod_fcgid.x86_64 0:2.3.9-4.el7 will be installed
---> Package mod_ssl.x86_64 1:2.4.6-17.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
 Package                     Arch                  Version                          Repository               Size
==================================================================================================================
Installing:
 crypto-utils                x86_64                2.4.1-42.el7                     Packages                 78 k
 httpd                       x86_64                2.4.6-17.el7                     Packages                1.2 M
 httpd-manual                noarch                2.4.6-17.el7                     Packages                1.3 M
 mod_fcgid                   x86_64                2.3.9-4.el7                      Packages                 79 k
 mod_ssl                     x86_64                1:2.4.6-17.el7                   Packages                 97 k

Transaction Summary
==================================================================================================================
Install  5 Packages

Total download size: 2.7 M
Installed size: 9.7 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): crypto-utils-2.4.1-42.el7.x86_64.rpm                                                |  78 kB  00:00:00     
(2/5): httpd-2.4.6-17.el7.x86_64.rpm                                                       | 1.2 MB  00:00:00     
(3/5): httpd-manual-2.4.6-17.el7.noarch.rpm                                                | 1.3 MB  00:00:00     
(4/5): mod_fcgid-2.3.9-4.el7.x86_64.rpm                                                    |  79 kB  00:00:00     
(5/5): mod_ssl-2.4.6-17.el7.x86_64.rpm                                                     |  97 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------
Total                                                                             9.6 MB/s | 2.7 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : httpd-2.4.6-17.el7.x86_64                                                                      1/5 
  Installing : mod_fcgid-2.3.9-4.el7.x86_64                                                                   2/5 
  Installing : httpd-manual-2.4.6-17.el7.noarch                                                               3/5 
  Installing : 1:mod_ssl-2.4.6-17.el7.x86_64                                                                  4/5 
  Installing : crypto-utils-2.4.1-42.el7.x86_64                                                               5/5 
  Verifying  : mod_fcgid-2.3.9-4.el7.x86_64                                                                   1/5 
  Verifying  : httpd-manual-2.4.6-17.el7.noarch                                                               2/5 
  Verifying  : crypto-utils-2.4.1-42.el7.x86_64                                                               3/5 
  Verifying  : 1:mod_ssl-2.4.6-17.el7.x86_64                                                                  4/5 
  Verifying  : httpd-2.4.6-17.el7.x86_64                                                                      5/5 

Installed:
  crypto-utils.x86_64 0:2.4.1-42.el7     httpd.x86_64 0:2.4.6-17.el7       httpd-manual.noarch 0:2.4.6-17.el7    
  mod_fcgid.x86_64 0:2.3.9-4.el7         mod_ssl.x86_64 1:2.4.6-17.el7    

Complete!
[[email protected] ~]# 

 






以上是关于Linux功能-使用YUM管理软件包的主要内容,如果未能解决你的问题,请参考以下文章

linux基础-第十六单元 yum管理RPM包

linux命令:yum软件包管理

喵呜:Linux环境基础开发工具使用篇之Linux 软件包管理器 yum

软件包管理 1 -----基本知识 rpm yum

Linux 软件包管理机制

Linux系统 rpm 与 yum的区别