YUM 是一个基于 RPM 的linux 包管理工具。他能够帮助我们自动升级软件,包括依赖的资源升级,也可以安装,卸载软件包。 这里是一些 YUM 的使用实例。希望大家更加的了解这款管理工具。
安装一个软件包,并安装与其相关的依赖软件。
示例:
[root@localhost ~]# yum install httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-26.el6.centos will be updated
---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be an update
--> Processing Dependency: httpd-tools = 2.2.15-29.el6.centos for package: httpd-2.2.15-29.el6.centos.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.15-26.el6.centos will be updated
---> Package httpd-tools.x86_64 0:2.2.15-29.el6.centos will be an update
--> Finished Dependency Resolution
如果未指定更新的软件包, yum 将更新所有软件。当我们进行指定, Yum 将会更新我们指定的软件
[root@localhost ~]# yum update httpd
Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Update Process
与update类似,可以添加一些参数,过时的软件如果需要处理(如删掉)可以添加 --obsolete 参数,或者使用 upgrade。如果需要更自动化一些的操作(避免回答一些问题)还可以增加一些参数,如: yum -y upgrade
[root@localhost ~]# yum upgrade httpd
Loaded plugins: fastestmirror,refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Upgrade Process
用于我们卸载一些无用软件。也会删除依赖我们们卸载软件的相关软件。
[root@localhost ~]# yum remove httpd
Loaded plugins: fastestmirror,refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be erased --> Processing Dependency: httpd-mmn = 20051115 for package: mod_perl-2.0.4-10.el6.x86_64 --> Processing Dependency: httpd >= 2.2.0 for package: gnome-user-share-2.28.2-3.el6.x86_64 --> Running transaction check ---> Package gnome-user-share.x86_64 0:2.28.2-3.el6 will be erased ---> Package mod_perl.x86_64 0:2.0.4-10.el6 will be erased --> Finished Dependency Resolution
[root@localhost ~]# yum list httpd
Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Installed Packages httpd.x86_64 2.2.15-29.el6.centos @base
[root@localhost ~]# yum info httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Installed Packages
Name : httpd
Arch : x86_64
Version : 2.2.15
Release : 29.el6.centos
Size : 2.9 M
Repo : installed
From repo : base
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible web server.
获得一切能找到的与 rpm 相关的程序,搜索的对象是每个程序的描述部分。
更详细的参数说明请查阅相关的 man pages。在 yum-utils 里面可以找到叫 yumdownloader 的程序。使用它可以方便下载,如 srpm 等包
yum search
yum search all
8.清楚无用的 rpm 如果做完一次系统级的升级,将会下载大量 rpm 等等东西,这将占用较多的硬盘,可以使用
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: Security-Updates base epel extras spacewalk-client updates
Cleaning up Everything
Cleaning up list of fastest mirrors
You have new mail in /var/spool/mail/root
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id repo name status
Security-Updates security-updates 1,154
base base 7,965
epel epel 14,597
extras extras 14
spacewalk-client spacewalk-client 21
updates updates 1,871
repolist: 25,622
yum grouplist:个相关的软件包会被放在一个特定的组内。大家安装某个软件组,这样就会安装该组所有的软件包。
yum groupinstall 'groupname': 安装某个指定软件组
yum groupremove 'groupname': 删除指定软件组
yum groupinfo 'groupname': 列出指定软件组信息
yum groupupdate 'groupname':升级指定软件组相关软件