当前位置:金沙js333娱乐场 > 网络频道 > 在红帽Linux中使用YUM包管理器金沙js333娱乐场

在红帽Linux中使用YUM包管理器金沙js333娱乐场

文章作者:网络频道 上传时间:2019-10-14

YUM是RHEL系统中提供的一个安装,卸载和搜索软件包的工具。它能做的不仅仅是安装、卸载软件包,它能做的还有更多,下面我们将在本文中为你展示。

YUM或Yellowdog Updater Modified是管理rpm包的前端工具。 它用于通过命令行界面或使用图形模式来安装,删除,更新和收集有关rpm软件包的信息。 使用YUM的主要优点是,它解决了rpm包的所有依赖关系,并将它们与包一起安装。

YUM可以自动安装软件包的依赖包,例如当你使用yum安装httpd时,它还会自动安装https apache server以及它依赖的软件包。通过rpm软件包安装时就没有这么方便咯(译注:就是不会自动处理软件包依赖问题咯!),你必须下载所有它依赖的软件包,然后依序安装它们。

下面让我们来讨论一些yum命令的例子。

yum工具从远端服务器上的软件仓库(通常由OS提供商提供)获取软件包的信息。一个软件仓库是能在特定架构上运行的一系列rpm软件包的集合。例如,对于32位和64位系统各有一个软件仓库,还有针对RHEL5以及RHEL6的软件仓库。你也可以建立一个本地仓库,配置你的yum让其从你的本地仓库里搜索安装软件包。在接下来的例子中,我将向你展示除了安装和卸载软件,yum还可以做的其它事情。为方便理解,我将在我的Amazon EC2 RHEL 6.4服务器上使用httpd软件包为例。

YUM命令的例子

从软件仓库里搜索软件包

# yum search httpd

Loaded plugins: amazon-id, rhui-lb, security
==================== N/S Matched: httpd ==========
httpd.x86_64 : Apache HTTP Server
httpd-devel.i686 : Development interfaces for the Apache HTTP server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
mod_dav_svn.x86_64 : Apache httpd module for Subversion server
mod_dnssd.x86_64 : An Apache HTTPD module which adds Zeroconf support

想获得详细的输出信息,可以使用下面的命令:

# yum provides httpd

Loaded plugins: amazon-id, rhui-lb, security
httpd-2.2.15-26.el6.x86_64 : Apache HTTP Server
Repo : rhui-REGION-rhel-server-releases
Matched from:

yum provides httpd在软件仓库里搜索含有httpd的软件包。

安装一个软件包  yum install httpd

提供所有软件组列表

# yum grouplist

以上命令将为你显示已经安装的以及可用的软件组。你可以使用软件组安装选项来安装其中一个软件组。例如,我们将安装一个PHP Support的软件组。这个软件组内包含需要的PHP软件包。

# yum groupinstall PHP Support

Loaded plugins: amazon-id, downloadonly, rhui-lb, security
Setting up Group Process
Warning: Group Support does not exist.
Resolving Dependencies
-> Running transaction check
--> Package php.x86_64 0:5.3.3-23.el6_4 will be installed
-> Processing Dependency: php-common(x86-64) = 5.3.3-23.el6_4 for package: php-5.3.3-23.el6_4.x86_64
-> Processing Dependency: php-cli(x86-64) = 5.3.3-23.el6_4 for package: php-5.3.3-23.el6_4.x86_64
--> Package php-gd.x86_64 0:5.3.3-23.el6_4 will be installed
-> Processing Dependency: libXpm.so.4()(64bit) for package: php-gd-5.3.3-23.el6_4.x86_64
--> Package php-pdo.x86_64 0:5.3.3-23.el6_4 will be installed
--> Package php-pear.noarch 1:1.9.4-4.el6 will be installed
--> Package php-xml.x86_64 0:5.3.3-23.el6_4 will be installed
-> Running transaction check
--> Package libXpm.x86_64 0:3.5.10-2.el6 will be installed
--> Package php-cli.x86_64 0:5.3.3-23.el6_4 will be installed
--> Package php-common.x86_64 0:5.3.3-23.el6_4 will be installed
-> Finished Dependency Resolution

Dependencies Resolved

==================================================
Package Arch Version Repository Size
==================================================
Installing:
php x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 1.1 M
php-gd x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 106 k
php-pdo x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 75 k
php-pear noarch 1:1.9.4-4.el6 rhui-REGION-rhel-server-releases 393 k
php-xml x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 103 k
Installing for dependencies:
libXpm x86_64 3.5.10-2.el6 rhui-REGION-rhel-server-releases 51 k
php-cli x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 2.2 M
php-common x86_64 5.3.3-23.el6_4 rhui-REGION-rhel-server-releases 524 k

Transaction Summary
==================================================
Install 8 Package(s)

Total download size: 4.5 M
Installed size: 16 M
Is this ok [y/N]: y

Downloading Packages:
(1/8): libXpm-3.5.10-2.el6.x86_64.rpm | 51 kB 00:00
(2/8): php-5.3.3-23.el6_4.x86_64.rpm | 1.1 MB 00:00
(3/8): php-cli-5.3.3-23.el6_4.x86_64.rpm | 2.2 MB 00:00
(4/8): php-common-5.3.3-23.el6_4.x86_64.rpm | 524 kB 00:00
(5/8): php-gd-5.3.3-23.el6_4.x86_64.rpm | 106 kB 00:00
(6/8): php-pdo-5.3.3-23.el6_4.x86_64.rpm | 75 kB 00:00
(7/8): php-pear-1.9.4-4.el6.noarch.rpm | 393 kB 00:00
(8/8): php-xml-5.3.3-23.el6_4.x86_64.rpm | 103 kB 00:00
-----------------------------------------------
Total 2.9 MB/s | 4.5 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-common-5.3.3-23.el6_4.x86_64 1/8
Installing : php-cli-5.3.3-23.el6_4.x86_64 2/8
Installing : libXpm-3.5.10-2.el6.x86_64 3/8
Installing : php-gd-5.3.3-23.el6_4.x86_64 4/8
Installing : 1:php-pear-1.9.4-4.el6.noarch 5/8
Installing : php-5.3.3-23.el6_4.x86_64 6/8
Installing : php-xml-5.3.3-23.el6_4.x86_64 7/8
Installing : php-pdo-5.3.3-23.el6_4.x86_64 8/8
Verifying : 1:php-pear-1.9.4-4.el6.noarch 1/8
Verifying : php-xml-5.3.3-23.el6_4.x86_64 2/8
Verifying : php-common-5.3.3-23.el6_4.x86_64 3/8
Verifying : libXpm-3.5.10-2.el6.x86_64 4/8
Verifying : php-cli-5.3.3-23.el6_4.x86_64 5/8
Verifying : php-5.3.3-23.el6_4.x86_64 6/8
Verifying : php-pdo-5.3.3-23.el6_4.x86_64 7/8
Verifying : php-gd-5.3.3-23.el6_4.x86_64 8/8

Installed:
php.x86_64 0:5.3.3-23.el6_4 php-gd.x86_64 0:5.3.3-23.el6_4 php-pdo.x86_64 0:5.3.3-23.el6_4
php-pear.noarch 1:1.9.4-4.el6 php-xml.x86_64 0:5.3.3-23.el6_4

Dependency Installed:
libXpm.x86_64 0:3.5.10-2.el6 php-cli.x86_64 0:5.3.3-23.el6_4 php-common.x86_64 0:5.3.3-23.el6_4

Complete!

金沙js333娱乐场 1

使用YUM安装软件包

可以使用yum install命令安装软件包,如下所示:

#  yum install httpd

Loaded plugins: amazon-id, rhui-lb, security
Setting up Install Process
Resolving Dependencies
-> Running transaction check
--> Package httpd.x86_64 0:2.2.15-29.el6_4 will be installed
-> Processing Dependency: httpd-tools = 2.2.15-29.el6_4 for package: httpd-2.2.15-29.el6_4.x86_64
-> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-29.el6_4.x86_64
-> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-29.el6_4.x86_64
-> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-29.el6_4.x86_64
-> Running transaction check
--> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
--> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
--> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
--> Package httpd-tools.x86_64 0:2.2.15-29.el6_4 will be installed
-> Finished Dependency Resolution

Dependencies Resolved

======================================================
Package Arch Version Repository Size
======================================================
Installing:
httpd x86_64 2.2.15-29.el6_4 rhui-REGION-rhel-server-releases 821 k
Installing for dependencies:
apr x86_64 1.3.9-5.el6_2 rhui-REGION-rhel-server-releases 123 k
apr-util x86_64 1.3.9-3.el6_0.1 rhui-REGION-rhel-server-releases 87 k
apr-util-ldap x86_64 1.3.9-3.el6_0.1 rhui-REGION-rhel-server-releases 15 k
httpd-tools x86_64 2.2.15-29.el6_4 rhui-REGION-rhel-server-releases 73 k

Transaction Summary
======================================================
Install 5 Package(s)

Total download size: 1.1 M
Installed size: 3.6 M
Is this ok [y/N]: y

如你所见,在安装httpd时yum安装了额外的软件包。这称为yum完成的依赖包解析。

假如你不想让yum弹出[y/N]选项,可以使用yum install -y httpd

删除一个包   yum remove httpd

使用yum update 命令更新一个已存在的软件包

# yum update httpd
Loaded plugins: amazon-id, rhui-lb, security
Setting up Update Process
No Packages marked for Update

这意味着你系统中安装的httpd软件包已经是yum软件仓库里的最新版本的了。

更多详情见请继续阅读下一页的精彩内容http://www.linuxidc.com/Linux/2013-11/92971p2.htm

推荐阅读:

配置EPEL YUM源 http://www.linuxidc.com/Linux/2012-10/71850.htm

RedHat金沙js333娱乐场, 本地yum源配置 http://www.linuxidc.com/Linux/2012-11/75127.htm

RedHat Linux 本地yum源的配置 http://www.linuxidc.com/Linux/2013-08/88217.htm

RedHat 6.2 Linux修改yum源免费使用CentOShttp://www.linuxidc.com/Linux/2013-07/87383.htm

更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

金沙js333娱乐场 2

金沙js333娱乐场 3

更新软件包  yum update httpd

金沙js333娱乐场 4

列出所有安装的软件包 yum list installed | less

在这里“| less“,所以我们可以浏览所有已安装的软件包。

列表单个包  yum list httpd

金沙js333娱乐场 5

列出所有捆绑的组包  yum grouplist

金沙js333娱乐场 6

安装一组包  yum groupinstall ‘Minimal Install’

金沙js333娱乐场 7

删除一个组包  yum groupremove ‘NFS fille server’

金沙js333娱乐场 8

搜索一个包  yum search httpd

金沙js333娱乐场 9

列出一个包的信息  yum info httpd

金沙js333娱乐场 10

找到属于哪个包的文件  yum provides /etc/httpd/conf/httpd.conf

金沙js333娱乐场 11

本文由金沙js333娱乐场发布于网络频道,转载请注明出处:在红帽Linux中使用YUM包管理器金沙js333娱乐场

关键词: