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操作结果

[3;J
[[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] ~]# 
时间: 2024-10-01 23:09:12

Linux功能-使用YUM管理软件包的相关文章

Linux 系列之Yum管理应用软件

1.        今天给大家带来的是关于Linux操作系统关于应用软件的管理,可能有些刚开始学习Linux的小伙伴对于Linux软件的安装删除不是特别了解,今天我就给大家介绍一种安装方式可以让你简单快速的安装使用丰富的应用软件.大家在平时安装应用软件时,大致可以分为两种,一种是下载安装包到本地进行安装,另一种就是像苹果的IOS系统一样,直接在线安装Apple Store 的应用就可以使用了,其实Linux应用软件的安装就和苹果一样,接下来就简单给大家说一下. 1.        首先要想学会L

linux进阶之yum管理

一.部署私有repo源 1.官网下载需要的仓库: rsync -avrt --delete rsync://mirrors.ustc.edu.cn/centos/7/cloud/x86_64/openstack-pike /export/download/cloud/ 2.安装软件包: yum install yum-utils createrepo nginx -y 3.创建yum源仓库: cd /export/download/ && createrepo cloud 4.创建并编辑n

使用&quot;yum&quot;管理软件包

1 安装新的软件包 su -c 'yum install tsclient' 安装包组 su -c 'yum groupinstall "MySQL Database" ' 2 更新程序包 su -c 'yum update tsclient' 更新包组 su -c 'yum groupupdate "MySQL Database" ' 3 卸载包(及依赖包) su -c 'yum remove tsclient' 卸载包组 su -c 'yum groupremo

Linux各发行版本及其软件包管理方法

Linux发行版本有很多,按照使用领域分为桌面系统领域和服务器领域.下面简要介绍如下: 1.Red Hat和Fedora:redhat最早发行的个人版本的Linux,自从Red Hat 9.0版本发布后,RedHat 公司就不再开发桌面版的 Linux发行套件,Red Hat Linux停止了开发,而将全部力量集中在服务器版的开发上,也就是 Red Hat Enterprise Linux 版.2004年4月30日,Red Hat公司正式停止对Red Hat 9.0版本的支援,标志著Red Ha

linux服务之yum

yum源服务器 yum客户端采用python编写,采用sqlite存储 yum的关键之处是要有可靠的repository,顾名思义,这是软件的仓库,它可以是http或ftp站点, 也可以是本地软件池,但必须包含rpm的header,header包括了rpm包的各种信息,包括描述,功能,提供的文件,依赖性等.正是收集了这些 header并加以分析,才能自动化地完成余下的任务.在执行yum update命令的时候,这一步就是yum会从服务器的header目录下载rpm的header,放在本地的缓存中

LINUX RPM、YUM软件包的管理

一.RPM.YUM 软件包管理管理工具的简介 1.首先讲一下自己的感觉:对于 初学linux的人来说安装软件是比较头疼的事,大家习惯了windos的操作,是中文的,只要上网一搜什么都有,然后下一步安装就行啦,卸载的话更是简单,在卸载或更改程序了么也很简单,还有360等.linux软件包大致分三种:以.rpm .压缩包.源码包最为常见,却他们的安装方法也是有差别的.掌握好软件安装卸载工具是以后搭建服务不可缺少的必备能力,而 RPM.YUM 就是不可或缺的利器. 2.rpm的简单介绍 1.可以安装.

Linux基础管理——软件包管理:rpm,yum高级使用方法(史上最全,没有之一)

前言: GRU Linux操作系统中,实现软件包管理的常见工具有RPM和yum:本专题将就Centos系统中安装包的命名.校验.密钥导入导出.包安装.卸载.升级.查询等众多rpm包管理相关的操作实现进行总结. 1.安装包 1.1.包管理器分类 二进制应用程序的组成部分:二进制文件.库文件.配置文件.帮助文件.所以包管理器就是对这四类文件进行分门别类存储的一个管理工具. 程序包管理器:     debian:deb文件, dpkg包管理器.         redhat: rpm文件, rpm包管

linux 从入门到跑路 - rpm ,yum , dnf (软件包管理三兄弟)

linux 从入门到跑路 - rpm ,yum , dnf (软件包管理三兄弟) 认识软件包管理 软件包管理是指系统中一种安装和维护软件的方法.今天,通过从 Linux 发行版中安装的软件包, 已能满足许多人所有需要的软件.这不同于早期的 Linux,人们需要下载和编辑源码来安装软件. 编辑源码没有任何问题,事实上,拥有对源码的访问权限是 Linux 的伟大奇迹.本篇,我们将查看一些用于包管理的命令行工具(rpm ,yum , dnf ).虽然所有主流 Linux 发行版都 提供了强大且精致的图

Linux基础之rpm软件包、yum管理rpm软件包

RPM就是Red Hat Package Manger(红帽软件包管理工具)的缩写. rpm的文件名分为5部分,其中: 第1部分是name,表示这个rpm软件包的名称: 第2部分是version,表示这个rpm软件包的版本编号: 第3部分是release,表示这个rpm软件包的版本发布次数(修正号码): 第4部分是architectures,表示这个rpm软件包适用于哪些平台: 最后一部分是rpm,表示这个rpm软件包的文件扩展名. rpm软件安装与移除工作中经常使用的选项: –i:安装(Ins