大纲

一、软件包相关

二、rpm实例详解

三、yum实例详解

四、创建本地yum仓库




一、软件包相关

1、软件包组成部分

    ①二进制程序,例如/bin /sbin

      ②库,例如/lib 

      ③配置文件,例如/etc

      ④帮助文档,例如/usr/share/man


2、软件包管理器的核心功能

     ①制作软件包

      ②安装、卸载、升级、查询、校验


3、rpm包命名格式

    name-version-release.arch.rpm

    如 vsftpd-2.3.5-1.el6.x86_64.rpm

name:包名

version:版本号包括主版本号、此版本号、修正号

    主版本号:重大改进

    次版本号:某个子功能发生重大变化

    修正号:修正了部分bug,调整了一点功能

release:发行号,rpm包制作者的发行号,与源程序作者没关系

arch:架构平台,包括系统平台与硬件平台


4、加密类型

①对称:加密解密使用同一个密钥,如DES、3DES、AES

②公钥:一对密钥,公钥(Public Key),私钥(Secret Key);公钥隐含于私钥中,可以提取出来,并公开出去;用作数据完整性校验,如DSA、RSA

③单向:又被称作散列加密,是用来提取数据特征码的,特点①雪崩效应②定长输出③不可逆;常用于数据完整性校验,如SHA1、MD5


5、yum仓库中的元数据文件

①primary.xml.gz:所有RPM包的列表;依赖关系;每个RPM安装生成的文件列表及属性信息

②filelists.xml.gz:当前仓库中所有RPM包的所有文件列表

③other.xml.gz:额外信息,RPM包的修改日志

④repomd.xml:记录的是上面三个文件的时间戳和校验和

⑤comps*.xml: RPM包分组信息



6、yum仓库主配置文件/etc/yum.conf

[root@soysauce test]# cat /etc/yum.conf 
[main]                                 # 主配置段
cachedir=/var/cache/yum/$basearch/$releasever                # yum的缓存目录,包括rpm包    
keepcache=0                                 # 是否保留缓存及rpm包
debuglevel=2                                 # debug级别
logfile=/var/log/yum.log                           # 日志文件路径定义
exactarch=1                                 # 严格检查Yum仓库中软件包与当前系统平台是否一致
obsoletes=1                                 # 过期内容是否废弃
gpgcheck=1                             # 是否检查rpm包来源合法性及完整性
plugins=1                              # 是否支持插件  
installonly_limit=5                      # 定义位于installpkgs里的包最多安装的次数      
distroverpkg=centos-release                         # rpm包发行版版本

7、定义repo文件

在/etc/yum.repos.d/目录下新建一个以repo结尾的文件,如test.repo
[Repo_ID]                                    # 仓库ID,不能与已有的仓库同名
name=Description                             # 注释信息,自定义
baseurl=   |  |                              # 定义yum仓库的路径,此处有三种方式定义
enabled={1|0}                                # 是否启用此yum仓库
gpgcheck={1|0}                               # 是否校验软件包的来源合法性以及完整性
gpgkey=                                      # 指定密钥文件路径

8、编译安装软件之后做的四件事

①修改PATH环境变量,以能够识别此程序的二进制文件路径

两种方式:

  • 修改/etc/profile文件

  • 在/etc/profile.d/目录建立一个以.sh为名称后缀的文件,在里面定义export PATH=$PATH:/path/to/somewhere

②输出库文件路径,默认情况下,系统搜索库文件的路径/lib, /usr/lib; 

在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,然后把增添的路径直接写至此文件中

# ldconfig 通知系统重新搜寻库文件,-v: 显示重新搜寻库的过程

③头文件:输出给系统默认:/usr/include,增添头文件搜寻路径,使用链接进行

两种方式:

ln -s /usr/local/tengine/include/* /usr/include/ 

ln -s /usr/local/tengine/include  /usr/include/tengine

④man文件路径:安装在--prefix指定的目录下的man目录;/usr/share/man

两种方式:

  • man -M /PATH/TO/MAN_DIR COMMAND

  • 在/etc/man.config中添加一条MANPATH



二、rpm详解

rpm - RPM Package Manager    # RPM包管理器

SYNOPSIS
   QUERYING AND VERIFYING PACKAGES:-q、-V、--import、-K
   INSTALLING, UPGRADING, AND REMOVING PACKAGES:-i、-U、-F、-e
   MISCELLANEOUS:--initdb、--addsign、--querytags、--setperms

1、安装

rpm -i /PATH/TO/PACKAGE_FILE
        
        -h: 以#显示进度;每个#表示2% 
        -v: 显示详细过程
        -vv: 更详细的过程
        --nodeps: 忽略依赖关系
        --replacepkgs: 重新安装,替换原有安装
        --force: 强行安装,可以实现重装或降级

(1)、安装时显示详细信息:-v

[root@soysauce test]# ls
corosync-1.4.7-2.el6.x86_64.rpm  vsftpd-2.2.2-14.el6.x86_64.rpm
[root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm   # 这个包没有依赖关系,顺利安装
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]

(2)、安装时忽略依赖关系:--nodeps

[root@soysauce test]# rpm -ivh corosync-1.4.7-2.el6.x86_64.rpm     # 这个包有依赖关系,装不上
Preparing...                ########################################### [100%]
	package corosync-1.4.7-2.el6.x86_64 is already installed
[root@soysauce test]# rpm -ivh --nodeps corosync-1.4.7-2.el6.x86_64.rpm   # --nodeps忽略依赖关系
Preparing...                ########################################### [100%]
	package corosync-1.4.7-2.el6.x86_64 is already installed    # 虽然装上去了,但是可能无法使用

(3)、重新安装某个已经安装过的软件:--replacepkgs

[root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm     
Preparing...                ########################################### [100%]
package vsftpd-2.2.2-14.el6.x86_64 is already installed    # 此时提示已经安装过了
[root@soysauce test]# rpm -ivh --replacepkgs vsftpd-2.2.2-14.el6.x86_64.rpm # 替换安装
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]

(4)、强制安装:--force

[root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
package vsftpd-2.2.2-14.el6.x86_64 is already installed    # 此时提示已经安装过了
[root@soysauce test]# rpm -ivh --force vsftpd-2.2.2-14.el6.x86_64.rpm # 强制安装
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]

(5)、测试能否安装:--test

[root@soysauce test]# rpm -e vsftpd    # 先卸载此rpm包 
[root@soysauce test]# rpm  -ivh --test vsftpd-2.2.2-14.el6.x86_64.rpm # 此时并没有安装,只是测试
Preparing...                ########################################### [100%]    
[root@soysauce test]# rpm -q vsftpd        # 查询是否安装此rpm包 
package vsftpd is not installed


2、查询

rpm   -q   PACKAGE_NAME
        
        rpm -q PACKAGE_NAME:查询指定的包是否已经安装
        rpm -qa:查询已经安装的所有包
        rpm -qi PACKAGE_NAME:查询指定包的说明信息
        rpm -ql PACKAGE_NAME:查询指定包安装后生成的文件列表
        rpm -qc PACEAGE_NEME:查询指定包安装的配置文件
        rpm -qd PACKAGE_NAME:查询指定包安装的帮助文件
        rpm -q --scripts PACKAGE_NAME:查询指定包中包含的脚本	
        rpm -qf /PATH/TO/SOMEFILE:查询指定的文件是由哪个rpm包安装生成的	
        rpm -qpi /PATH/TO/PACKAGE_FILE:查询尚未安装的软件包的说明信息
        rpm -qpl /PATH/TO/PACKAGE_FILE:查询尚未安装的软件包安装后会生成的文件列表

(1)、查询指定的包是否已经安装:-q

[root@soysauce test]# rpm -q vsftpd
vsftpd-2.2.2-14.el6.x86_64

(2)、查询已经安装的所有包:-qa

[root@soysauce test]# rpm -qa | grep "vsftpd"
vsftpd-2.2.2-14.el6.x86_64

(3)、查询指定包的说明信息:-qi

[root@soysauce test]# rpm -qi vsftpd    
package vsftpd is not installed
[root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]
[root@soysauce test]# rpm -qi vsftpd
Name        : vsftpd                       Relocations: (not relocatable)
Version     : 2.2.2                             Vendor: CentOS
Release     : 14.el6                        Build Date: Fri 24 Jul 2015 08:49:50 AM CST
Install Date: Sun 29 Nov 2015 08:32:19 PM CST      Build Host: c6b8.bsys.dev.centos.org
Group       : System Environment/Daemons    Source RPM: vsftpd-2.2.2-14.el6.src.rpm
Size        : 339540                           License: GPLv2 with exceptions
Signature   : RSA/SHA1, Sat 25 Jul 2015 04:41:15 AM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://vsftpd.beasts.org/
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.

(4)、查询指定包安装后生成的文件列表:-ql

[root@soysauce test]# rpm -ql vsftpd |head -10    # 因为篇幅原因,顾只选取前10行
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-2.2.2

(5)、查询指定包安装的配置文件:-qc

[root@soysauce test]# rpm -qc vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf

(6)、查询指定包安装的帮助文件:-qd

[root@soysauce test]# rpm -qd vsftpd
/usr/share/doc/vsftpd-2.2.2/AUDIT
/usr/share/doc/vsftpd-2.2.2/BENCHMARKS
/usr/share/doc/vsftpd-2.2.2/BUGS
/usr/share/doc/vsftpd-2.2.2/COPYING
/usr/share/doc/vsftpd-2.2.2/Changelog
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-2.2.2/FAQ
/usr/share/doc/vsftpd-2.2.2/INSTALL
/usr/share/doc/vsftpd-2.2.2/LICENSE
/usr/share/doc/vsftpd-2.2.2/README
/usr/share/doc/vsftpd-2.2.2/README.security
/usr/share/doc/vsftpd-2.2.2/REWARD
/usr/share/doc/vsftpd-2.2.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-2.2.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-2.2.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-2.2.2/SECURITY/TRUST
/usr/share/doc/vsftpd-2.2.2/SIZE
/usr/share/doc/vsftpd-2.2.2/SPEED
/usr/share/doc/vsftpd-2.2.2/TODO
/usr/share/doc/vsftpd-2.2.2/TUNING
/usr/share/doc/vsftpd-2.2.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz

(7)、查询指定包中包含的脚本:-q --scripts    

[root@soysauce test]# rpm -q --scripts vsftpd
postinstall scriptlet (using /bin/sh):        # 安装后脚本
/sbin/chkconfig --add vsftpd
preuninstall scriptlet (using /bin/sh):        # 卸载前脚本
if [ $1 = 0 ]; then
 /sbin/service vsftpd stop > /dev/null 2>&1
 /sbin/chkconfig --del vsftpd
fi

(8)、查询指定的文件是由哪个rpm包安装生成的:-qf

[root@soysauce test]# rpm -qf /usr/share/man/man5/vsftpd.conf.5.gz
vsftpd-2.2.2-14.el6.x86_64

(9)、rpm包尚未安装:-qp

[root@soysauce test]# ls
corosync-1.4.7-2.el6.x86_64.rpm  vsftpd-2.2.2-14.el6.x86_64.rpm
[root@soysauce test]# rpm -q corosync                    # 此时corosync尚未安装
package corosync is not installed
[root@soysauce test]# rpm -qi corosync-1.4.7-2.el6.x86_64.rpm # -q只能查询已经安装的软件包
package corosync-1.4.7-2.el6.x86_64.rpm is not installed
[root@soysauce test]# rpm -qpi corosync-1.4.7-2.el6.x86_64.rpm # 加上-p选项即可
Name        : corosync                     Relocations: (not relocatable)
Version     : 1.4.7                             Vendor: CentOS
Release     : 2.el6                         Build Date: Fri 24 Jul 2015 07:12:34 AM CST
Install Date: (not installed)               Build Host: c6b9.bsys.dev.centos.org
Group       : System Environment/Base       Source RPM: corosync-1.4.7-2.el6.src.rpm
Size        : 448791                           License: BSD
Signature   : RSA/SHA1, Sat 25 Jul 2015 04:38:44 AM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://ftp.corosync.org
Summary     : The Corosync Cluster Engine and Application Programming Interfaces
Description :
This package contains the Corosync Cluster Engine Executive, several default
APIs and libraries, default configuration files, and an init script.


3、升级

rpm -Uvh /PATH/TO/NEW_PACKAGE_FILE: 如果装有老版本的,则升级;否则,则安装
rpm -Fvh /PATH/TO/NEW_PACKAGE_FILE:如果装有老版本的,则升级;否则,退出
      --oldpackage: 降级

(1)、如果装有老版本的,则升级;否则,则安装:-Uvh

[root@soysauce test]# rpm -ivh vsftpd-2.3.5-1.el6.x86_64.rpm     # 提示与旧版本有冲突
Preparing...                ########################################### [100%]
file /etc/logrotate.d/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /etc/pam.d/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /etc/rc.d/init.d/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /usr/sbin/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /etc/vsftpd/ftpusers from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /etc/vsftpd/user_list from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /etc/vsftpd/vsftpd.conf from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /etc/vsftpd/vsftpd_conf_migrate.sh from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /usr/share/man/man5/vsftpd.conf.5.gz from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
file /usr/share/man/man8/vsftpd.8.gz from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64
[root@soysauce test]# rpm -Uvh vsftpd-2.3.5-1.el6.x86_64.rpm     # 因为装有老版本,所以-Uvh可以直接升级
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]
[root@soysauce test]# rpm -q vsftpd
vsftpd-2.3.5-1.el6.x86_64                        # 可以看到已经成功升级

(2)如果装有老版本的,则升级;否则,退出:-Fvh

[root@soysauce test]# rpm -q lftp    
package lftp is not installed                # lftp没有安装
[root@soysauce test]# rpm -Fvh lftp-4.0.9-6.el6.x86_64.rpm # 因为没有装老版本,所以退出
[root@soysauce test]# rpm -q lftp
package lftp is not installed                # 可以看到并没有安装上去
[root@soysauce test]# rpm -q vsftpd
vsftpd-2.2.2-14.el6.x86_64                        # vsftpd是安装过的
[root@soysauce test]# rpm -Fvh vsftpd-2.3.5-1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]
[root@soysauce test]# rpm -q vsftpd
vsftpd-2.3.5-1.el6.x86_64                        # 可以看到已经成功升级

(3)、降级:--oldpackage

[root@soysauce test]# rpm -q vsftpd
vsftpd-2.3.5-1.el6.x86_64                    # 此时是2.3.5-1版本的vsftpd包
[root@soysauce test]# rpm -Uvh vsftpd-2.2.2-14.el6.x86_64.rpm     # 提示安装的包是老版本的包
Preparing...                ########################################### [100%]
package vsftpd-2.3.5-1.el6.x86_64 (which is newer than vsftpd-2.2.2-14.el6.x86_64) is already installed
[root@soysauce test]# rpm -Uvh --oldpackage vsftpd-2.2.2-14.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]
[root@soysauce test]# rpm -q vsftpd
vsftpd-2.2.2-14.el6.x86_64                    # 成功降级为2.2.2-14版本的vsftpd包



4卸载

rpm   -e   PACKAGE_NAME
[root@soysauce test]# rpm -q vsftpd
vsftpd-2.2.2-14.el6.x86_64
[root@soysauce test]# rpm -e vsftpd        # 如果没有依赖关系,是可以直接卸载的
[root@soysauce test]# rpm -q vsftpd
package vsftpd is not installed            # 卸载成功


5、校验

rpm   -V   PACKAGE_NAME
[root@soysauce test]# rpm -V vsftpd        # 校验发现没有被修改过
[root@soysauce test]# rpm -qc vsftpd        # 查询vsftpd包生成的配置文件
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
[root@soysauce test]# echo "A new line" >> /etc/vsftpd/vsftpd.conf     # 新增一行内容
[root@soysauce test]# rpm -V vsftpd            
S.5....T.  c /etc/vsftpd/vsftpd.conf                   # 再次校验发现有了改动

各字段属性含义:
       S file Size differs                    # 文件大小发生改变
       M Mode differs (includes permissions and file type)    # 权限或文件类型改变
       5 digest (formerly MD5 sum) differs        # MD5值发生改变
       D Device major/minor number mismatch        # 设备主、次设备号不匹配
       L readLink(2) path mismatch            # 读取链接路径不匹配
       U User ownership differs             # 属主发生改变
       G Group ownership differs            # 属组发生改变
       T mTime differs                  # 修改时间戳发生变化
       P caPabilities differ               # 功能发生改变


6、重建数据库

rpm --rebuilddb:重建数据库,一定会重新建立
rpm --initdb:初始化数据库,没有才建立,有就不用建立

(1)、初始化数据库,没有才建立,有就不用建立:--initdb

[root@soysauce test]# ls /var/lib/rpm/        # rpm包信息数据库所在目录
Basenames     Filedigests  Name          Providename     Requirename     Sigmd5
Conflictname  Group        Obsoletename  Provideversion  Requireversion  Triggername
Dirnames      Installtid   Packages      Pubkeys         Sha1header
[root@soysauce test]# rpm --initdb            # 已经有rpm包的数据库,并没有重新生成

(2)、重建数据库,一定会重新建立:--rebuilddb

[root@soysauce test]# ls /var/lib/rpm/
Basenames     __db.002  Dirnames     Installtid    Packages        Pubkeys         Sha1header
Conflictname  __db.003  Filedigests  Name          Providename     Requirename     Sigmd5
__db.001      __db.004  Group        Obsoletename  Provideversion  Requireversion  Triggername
[root@soysauce test]# rpm --rebuilddb        # 已经有rpm包的数据库,但还是会重新生成


7、检验来源合法性,及软件包完整性

rpm -K /PAPT/TO/PACKAGE_FILE
        dsa, gpg:验正来源合法性,也即验正签名;可以使用--nosignature,略过此项
        sha1, md5:验正软件包完整性;可以使用--nodigest,略过此项
        
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6     # 导入密钥文件

(1)、验证软件包来源合法性以及完整性:-K

[root@soysauce test]# rpm -K corosync-1.4.7-2.el6.x86_64.rpm 
corosync-1.4.7-2.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK    # 全部都OK

(2)、只验证软件包来源合法性:-K --nodigest

[root@soysauce test]# rpm -K --nodigest  corosync-1.4.7-2.el6.x86_64.rpm 
corosync-1.4.7-2.el6.x86_64.rpm: rsa (md5) pgp OK    # rsa、gpg验证软件包来源合法性

(3)、只验证软件包完整性:-K --nosignature

[root@soysauce test]# rpm -K --nosignature  corosync-1.4.7-2.el6.x86_64.rpm 
corosync-1.4.7-2.el6.x86_64.rpm: sha1 md5 OK            # sha1、md5验证软件包完整性



三、yum

yum - Yellowdog Updater Modified

SYNOPSIS
       yum [options] [command] [package ...]
       
        install package1 [package2] [...]
        * update [package1] [package2] [...]
        * update-to [package1] [package2] [...]
        * check-update
        * upgrade [package1] [package2] [...]
        * upgrade-to [package1] [package2] [...]
        * distribution-synchronization [package1] [package2] [...]
        * remove | erase package1 [package2] [...]
        * list [...]
        * info [...]
        * provides | whatprovides feature1 [feature2] [...]
        * clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]
        * makecache
        * groupinstall group1 [group2] [...]
        * groupupdate group1 [group2] [...]
        * grouplist [hidden] [groupwildcard] [...]
        * groupremove group1 [group2] [...]
        * groupinfo group1 [...]
        * search string1 [string2] [...]
        * shell [filename]
        * resolvedep dep1 [dep2] [...]
        * localinstall rpmfile1 [rpmfile2] [...]
           (maintained for legacy reasons only - use install)
        * localupdate rpmfile1 [rpmfile2] [...]
           (maintained for legacy reasons only - use update)
        * reinstall package1 [package2] [...]
        * downgrade package1 [package2] [...]
        * deplist package1 [package2] [...]
        * repolist [all|enabled|disabled]

1、安装

(1)、安装yum仓库中的软件包

yum  install  PACKAGE_NAME...
        -y:自动回答为yes
        --nogpgcheck:不进行gpg校验
        
[root@soysauce yum.repos.d]# rpm -q lftp
package lftp is not installed                        # lftp尚未安装
[root@soysauce yum.repos.d]# yum install -y lftp            
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lftp.x86_64 0:4.0.9-6.el6 will be installed
--> Processing Dependency: libgnutls.so.26(GNUTLS_1_4)(64bit) for package: lftp-4.0.9-6.el6.x86_64
--> Processing Dependency: libgnutls.so.26()(64bit) for package: lftp-4.0.9-6.el6.x86_64
--> Running transaction check
---> Package gnutls.x86_64 0:2.8.5-18.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================
 Package                   Arch                      Version                           Repository               Size
=====================================================================================================================
Installing:
 lftp                      x86_64                    4.0.9-6.el6                       base                    752 k
Installing for dependencies:
 gnutls                    x86_64                    2.8.5-18.el6                      base                    347 k

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

Total download size: 1.1 M
Installed size: 3.5 M
Downloading Packages:
(1/2): gnutls-2.8.5-18.el6.x86_64.rpm                                                         | 347 kB     00:00     
(2/2): lftp-4.0.9-6.el6.x86_64.rpm                                                            | 752 kB     00:00     
---------------------------------------------------------------------------------------------------------------------
Total                                                                                860 kB/s | 1.1 MB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
corosynclib-1.4.7-2.el6.x86_64 has missing requires of corosync = ('0', '1.4.7', '2.el6')
  Installing : gnutls-2.8.5-18.el6.x86_64                                                                        1/2 
  Installing : lftp-4.0.9-6.el6.x86_64                                                                           2/2 
  Verifying  : lftp-4.0.9-6.el6.x86_64                                                                           1/2 
  Verifying  : gnutls-2.8.5-18.el6.x86_64                                                                        2/2 

Installed:
  lftp.x86_64 0:4.0.9-6.el6                                                                                          

Dependency Installed:
  gnutls.x86_64 0:2.8.5-18.el6                                                                                       

Complete!
[root@soysauce yum.repos.d]#  rpm -q lftp
lftp-4.0.9-6.el6.x86_64                                # 此时可以看到已成功安装,自动解决依赖关系

(2)、重新安装某个已安装过的软件:reinstall

[root@soysauce yum.repos.d]# rpm -q lftp
lftp-4.0.9-6.el6.x86_64                            # 此时可以看到lftp已经安装过了
[root@soysauce yum.repos.d]# yum reinstall -y lftp
Loaded plugins: fastestmirror
Setting up Reinstall Process
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package lftp.x86_64 0:4.0.9-6.el6 will be reinstalled
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================
 Package                  Arch                       Version                          Repository                Size
=====================================================================================================================
Reinstalling:
 lftp                     x86_64                     4.0.9-6.el6                      base                     752 k
Transaction Summary
=====================================================================================================================
Reinstall     1 Package(s)
Total download size: 752 k
Installed size: 2.5 M
Downloading Packages:
lftp-4.0.9-6.el6.x86_64.rpm                                                                   | 752 kB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : lftp-4.0.9-6.el6.x86_64                                                                           1/1 
  Verifying  : lftp-4.0.9-6.el6.x86_64                                                                           1/1 
Installed:
  lftp.x86_64 0:4.0.9-6.el6                                                                                          
Complete!

(3)、安装一个本地rpm包:localinstall

[root@soysauce test]# rpm -ivh corosync-1.4.7-2.el6.x86_64.rpm     # 提示缺少依赖关系,无法安装
error: Failed dependencies:
	corosynclib = 1.4.7-2.el6 is needed by corosync-1.4.7-2.el6.x86_64
	libcfg.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libcfg.so.4(COROSYNC_CFG_0.82)(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libconfdb.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libconfdb.so.4(COROSYNC_CONFDB_1.0)(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libcoroipcc.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libcoroipcs.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libcpg.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libcpg.so.4(COROSYNC_CPG_1.0)(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	liblogsys.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libpload.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libpload.so.4(COROSYNC_PLOAD_1.0)(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libquorum.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libquorum.so.4(COROSYNC_QUORUM_1.0)(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libtotem_pg.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libvotequorum.so.4()(64bit) is needed by corosync-1.4.7-2.el6.x86_64
	libvotequorum.so.4(COROSYNC_VOTEQUORUM_1.0)(64bit) is needed by corosync-1.4.7-2.el6.x86_64
[root@soysauce test]# yum localinstall corosync-1.4.7-2.el6.x86_64.rpm 
Loaded plugins: fastestmirror
Setting up Local Package Process
Examining corosync-1.4.7-2.el6.x86_64.rpm: corosync-1.4.7-2.el6.x86_64
Marking corosync-1.4.7-2.el6.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package corosync.x86_64 0:1.4.7-2.el6 will be installed
--> Processing Dependency: corosynclib = 1.4.7-2.el6 for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libcfg.so.4(COROSYNC_CFG_0.82)(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libconfdb.so.4(COROSYNC_CONFDB_1.0)(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libcpg.so.4(COROSYNC_CPG_1.0)(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libpload.so.4(COROSYNC_PLOAD_1.0)(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libquorum.so.4(COROSYNC_QUORUM_1.0)(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libvotequorum.so.4(COROSYNC_VOTEQUORUM_1.0)(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libcfg.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libconfdb.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libcoroipcc.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libcoroipcs.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libcpg.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: liblogsys.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libpload.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libquorum.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libtotem_pg.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Processing Dependency: libvotequorum.so.4()(64bit) for package: corosync-1.4.7-2.el6.x86_64
--> Running transaction check
---> Package corosynclib.x86_64 0:1.4.7-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                  Arch                Version                   Repository                                 Size
========================================================================================================================
Installing:
 corosync                 x86_64              1.4.7-2.el6               /corosync-1.4.7-2.el6.x86_64              438 k
Installing for dependencies:
 corosynclib              x86_64              1.4.7-2.el6               base                                      192 k

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

Total size: 630 k
Total download size: 192 k
Installed size: 859 k
Is this ok [y/N]: y
Downloading Packages:
corosynclib-1.4.7-2.el6.x86_64.rpm                                                               | 192 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : corosync-1.4.7-2.el6.x86_64                                                                          1/2 
  Installing : corosynclib-1.4.7-2.el6.x86_64                                                                       2/2 
  Verifying  : corosynclib-1.4.7-2.el6.x86_64                                                                       1/2 
  Verifying  : corosync-1.4.7-2.el6.x86_64                                                                          2/2 

Installed:
  corosync.x86_64 0:1.4.7-2.el6                                                                                         

Dependency Installed:
  corosynclib.x86_64 0:1.4.7-2.el6                                                                                      

Complete!
[root@soysauce test]# rpm -q corosync
corosync-1.4.7-2.el6.x86_64                    # 可以看到已经成功安装


2、查询

(1)、查询指定的包是否已经安装:list

[root@soysauce test]# yum list lftp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Installed Packages                                        # 已安装的包
lftp.x86_64                                              4.0.9-6.el6                                               @base
Available Packages                                         # 可安装的包
lftp.i686                                                4.0.9-6.el6                                               base

(2)、查询已经安装的所有包:list all

[root@soysauce ~]# yum list all | grep "vim"        # 查找包含vim字符串的包
vim-common.x86_64                           2:7.4.629-5.el6              @base  
vim-enhanced.x86_64                         2:7.4.629-5.el6              @base  
vim-filesystem.x86_64                       2:7.4.629-5.el6              @base  
vim-minimal.x86_64                          2:7.2.411-1.8.el6            @anaconda-CentOS-201311272149.x86_64/6.5
beakerlib-vim-syntax.noarch                 1.11-1.el6                   epel   
docker-io-vim.x86_64                        1.7.1-2.el6                  epel   
protobuf-vim.x86_64                         2.3.0-9.el6                  epel   
vim-X11.x86_64                              2:7.4.629-5.el6              base   
vim-clustershell.noarch                     1.7-1.el6                    epel   
vim-halibut.noarch                          1.0-2.20100504svn8934.el6    epel   
vim-minimal.x86_64                          2:7.4.629-5.el6              base

(3) 、查询仓库中包的说明信息:info

[root@soysauce test]# yum info corosync
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Installed Packages
Name        : corosync
Arch        : x86_64
Version     : 1.4.7
Release     : 2.el6
Size        : 438 k
Repo        : installed
From repo   : /corosync-1.4.7-2.el6.x86_64
Summary     : The Corosync Cluster Engine and Application Programming Interfaces
URL         : http://ftp.corosync.org
License     : BSD
Description : This package contains the Corosync Cluster Engine Executive, several default
            : APIs and libraries, default configuration files, and an init script.

(4)、查询某个命令是由哪个包提供的:provides

[root@soysauce test]# yum provides "/bin/ls"        # 查询/bin/ls由哪个包提供
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
coreutils-8.4-37.el6_7.3.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : updates
Matched from:
Filename    : /bin/ls



coreutils-8.4-37.el6.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : base
Matched from:
Filename    : /bin/ls



coreutils-8.4-31.el6.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : installed
Matched from:
Other       : Provides-match: /bin/ls

(5)、查询所有的yum仓库:repolist

[root@soysauce test]# yum repolist    
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
repo id                              repo name                                                                    status
base                                 CentOS-6 - Base - 163.com                                                     6,575
*epel                                Extra Packages for Enterprise Linux 6 - x86_64                               11,882
extras                               CentOS-6 - Extras - 163.com                                                      45
updates                              CentOS-6 - Updates - 163.com                                                    670
repolist: 19,172

(6)、查询某个包的依赖关系:deplist

[root@soysauce test]# yum deplist vsftpd | head -20        # 因为篇幅原因,顾只取前20行
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Finding dependencies: 
package: vsftpd.x86_64 2.2.2-14.el6
  dependency: libssl.so.10()(64bit)
   provider: openssl.x86_64 1.0.1e-42.el6
  dependency: libnsl.so.1()(64bit)
   provider: glibc.x86_64 2.12-1.166.el6
   provider: glibc.x86_64 2.12-1.166.el6_7.1
   provider: glibc.x86_64 2.12-1.166.el6_7.3
  dependency: /sbin/service
   provider: initscripts.x86_64 9.03.49-1.el6.centos
   provider: initscripts.x86_64 9.03.49-1.el6.centos.2
   provider: initscripts.x86_64 9.03.49-1.el6.centos.1
  dependency: logrotate
   provider: logrotate.x86_64 3.7.8-23.el6
   provider: logrotate.x86_64 3.7.8-25.el6_7
  dependency: /bin/bash
   provider: bash.x86_64 4.1.2-33.el6


3、升级

(1)、查询所有可升级的软件包:check-update

[root@soysauce test]# yum check-update |head -10        # 因为篇幅原因,顾只取前10行
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net

ansible.noarch                           1.9.4-1.el6                     epel   
audit.x86_64                             2.3.7-5.el6                     base   
audit-libs.x86_64                        2.3.7-5.el6                     base   
authconfig.x86_64                        6.1.12-23.el6                   base   
b43-openfwwf.noarch                      5.2-10.el6                      base   
bash.x86_64                              4.1.2-33.el6_7.1                updates


Exiting on Broken Pipe

(2)、升级软件包:update

[root@soysauce test]# rpm -q tar
tar-1.23-11.el6.x86_64                                    # 此时tar为1.23-11的版本
[root@soysauce test]# yum update tar
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package tar.x86_64 2:1.23-11.el6 will be updated
---> Package tar.x86_64 2:1.23-13.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                 Arch                       Version                              Repository                Size
========================================================================================================================
Updating:
 tar                     x86_64                     2:1.23-13.el6                        base                     809 k

Transaction Summary
========================================================================================================================
Upgrade       1 Package(s)

Total download size: 809 k
Is this ok [y/N]: y
Downloading Packages:
tar-1.23-13.el6.x86_64.rpm                                                                       | 809 kB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : 2:tar-1.23-13.el6.x86_64                                                                             1/2 
  Cleanup    : 2:tar-1.23-11.el6.x86_64                                                                             2/2 
  Verifying  : 2:tar-1.23-13.el6.x86_64                                                                             1/2 
  Verifying  : 2:tar-1.23-11.el6.x86_64                                                                             2/2 

Updated:
  tar.x86_64 2:1.23-13.el6                                                                                                        

Complete!
[root@soysauce test]# rpm -q tar
tar-1.23-13.el6.x86_64                          # 此时可以看到已经升级到了1.23-13的版本


4、卸载

yum  remove  PACKAGE_NAME

[root@soysauce test]# rpm -q corosync
corosync-1.4.7-2.el6.x86_64                        # corosync已经安装了
[root@soysauce test]# yum remove corosync
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package corosync.x86_64 0:1.4.7-2.el6 will be erased
--> Processing Dependency: corosync = 1.4.7-2.el6 for package: corosynclib-1.4.7-2.el6.x86_64
--> Running transaction check
---> Package corosynclib.x86_64 0:1.4.7-2.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================
 Package                  Arch                Version                  Repository                                  Size
========================================================================================================================
Removing:
 corosync                 x86_64              1.4.7-2.el6              @/corosync-1.4.7-2.el6.x86_64              438 k
Removing for dependencies:
 corosynclib              x86_64              1.4.7-2.el6              @base                                      421 k
Transaction Summary
========================================================================================================================
Remove        2 Package(s)
Installed size: 859 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : corosync-1.4.7-2.el6.x86_64                                                                          1/2 
  Erasing    : corosynclib-1.4.7-2.el6.x86_64                                                                       2/2 
  Verifying  : corosynclib-1.4.7-2.el6.x86_64                                                                       1/2 
  Verifying  : corosync-1.4.7-2.el6.x86_64                                                                          2/2 
Removed:
  corosync.x86_64 0:1.4.7-2.el6                                                                                         
Dependency Removed:
  corosynclib.x86_64 0:1.4.7-2.el6                                                                                      
Complete!
[root@soysauce test]# rpm -q corosync
package corosync is not installed                      # 此时可以看到已经卸载了


5、缓存

(1)、清除缓存:clean

[root@soysauce test]# yum clean all    # 清楚yum仓库元数据信息和缓存的rpm包
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors

(2)、新建缓存:makecache

[root@soysauce test]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/metalink                                                                                    | 4.6 kB     00:00     
 * epel: mirror01.idc.hinet.net
base                                                                                             | 3.7 kB     00:00     
base/group_gz                                                                                    | 219 kB     00:00     
base/filelists_db                                                                                | 6.3 MB     00:05     
base/primary_db                                                                                  | 4.6 MB     00:04     
base/other_db                                                                                    | 2.8 MB     00:02     
epel                                                                                             | 4.3 kB     00:00     
epel/filelists_db                                                                                | 8.1 MB     02:19     
epel/updateinfo                                                                                  | 706 kB     00:01     
epel/primary_db                                                                                  | 5.8 MB     00:23     
epel/other_db                                                                                    | 2.9 MB     00:10     
extras                                                                                           | 3.4 kB     00:00     
extras/filelists_db                                                                              |  36 kB     00:00     
extras/prestodelta                                                                               |  601 B     00:00     
extras/primary_db                                                                                |  33 kB     00:00     
extras/other_db                                                                                  |  47 kB     00:00     
updates                                                                                          | 3.4 kB     00:00     
updates/filelists_db                                                                             | 2.1 MB     00:02     
updates/prestodelta                                                                              | 210 kB     00:01     
updates/primary_db                                                                               | 2.6 MB     00:05     
updates/other_db                                                                                 |  31 MB     00:35     
Metadata Cache Created


6、软件包组管理

(1)、查看软件包组信息:groupinfo

[root@soysauce test]#  yum groupinfo "Emacs"
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net

Group: Emacs
 Description: The GNU Emacs extensible, customizable, text editor.
 Mandatory Packages:
   emacs
 Optional Packages:
   ctags-etags
   emacs-auctex
   emacs-gnuplot
   emacs-nox

(2)、安装软件包组:groupinstall

[root@soysauce test]# yum groupinstall "Emacs"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Setting up Group Process
Checking for new repos for mirrors
Resolving Dependencies
--> Running transaction check
---> Package emacs.x86_64 1:23.1-28.el6 will be installed
--> Processing Dependency: emacs-common = 1:23.1-28.el6 for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: m17n-db-datafiles for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: librsvg2 for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: desktop-file-utils for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: librsvg-2.so.2()(64bit) for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: libotf.so.0()(64bit) for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: libm17n-flt.so.0()(64bit) for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: libm17n-core.so.0()(64bit) for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: libgif.so.4()(64bit) for package: 1:emacs-23.1-28.el6.x86_64
--> Processing Dependency: libXpm.so.4()(64bit) for package: 1:emacs-23.1-28.el6.x86_64
--> Running transaction check
---> Package desktop-file-utils.x86_64 0:0.15-9.el6 will be installed
---> Package emacs-common.x86_64 1:23.1-28.el6 will be installed
---> Package giflib.x86_64 0:4.1.6-3.1.el6 will be installed
---> Package libXpm.x86_64 0:3.5.10-2.el6 will be installed
---> Package libotf.x86_64 0:0.9.9-3.1.el6 will be installed
--> Processing Dependency: libXt.so.6()(64bit) for package: libotf-0.9.9-3.1.el6.x86_64
--> Processing Dependency: libXmu.so.6()(64bit) for package: libotf-0.9.9-3.1.el6.x86_64
--> Processing Dependency: libXaw.so.7()(64bit) for package: libotf-0.9.9-3.1.el6.x86_64
---> Package librsvg2.x86_64 0:2.26.0-14.el6 will be installed
--> Processing Dependency: libgsf >= 1.6.0 for package: librsvg2-2.26.0-14.el6.x86_64
--> Processing Dependency: libgsf-1.so.114()(64bit) for package: librsvg2-2.26.0-14.el6.x86_64
--> Processing Dependency: libcroco-0.6.so.3()(64bit) for package: librsvg2-2.26.0-14.el6.x86_64
---> Package m17n-db-datafiles.noarch 0:1.5.5-1.1.el6 will be installed
--> Processing Dependency: m17n-db = 1.5.5-1.1.el6 for package: m17n-db-datafiles-1.5.5-1.1.el6.noarch
---> Package m17n-lib.x86_64 0:1.5.5-2.el6_1.1 will be installed
--> Running transaction check
---> Package libXaw.x86_64 0:1.0.11-2.el6 will be installed
---> Package libXmu.x86_64 0:1.1.1-2.el6 will be installed
---> Package libXt.x86_64 0:1.1.4-6.1.el6 will be installed
---> Package libcroco.x86_64 0:0.6.2-5.el6 will be installed
---> Package libgsf.x86_64 0:1.14.15-5.el6 will be installed
--> Processing Dependency: GConf2 for package: libgsf-1.14.15-5.el6.x86_64
--> Processing Dependency: GConf2 for package: libgsf-1.14.15-5.el6.x86_64
---> Package m17n-db.noarch 0:1.5.5-1.1.el6 will be installed
--> Running transaction check
---> Package GConf2.x86_64 0:2.28.0-6.el6 will be installed
--> Processing Dependency: sgml-common for package: GConf2-2.28.0-6.el6.x86_64
--> Processing Dependency: dbus for package: GConf2-2.28.0-6.el6.x86_64
--> Processing Dependency: libpolkit-gobject-1.so.0()(64bit) for package: GConf2-2.28.0-6.el6.x86_64
--> Processing Dependency: libORBit-2.so.0()(64bit) for package: GConf2-2.28.0-6.el6.x86_64
--> Running transaction check
---> Package ORBit2.x86_64 0:2.14.17-5.el6 will be installed
--> Processing Dependency: libIDL-2.so.0()(64bit) for package: ORBit2-2.14.17-5.el6.x86_64
---> Package dbus.x86_64 1:1.2.24-8.el6_6 will be installed
--> Processing Dependency: dbus-libs = 1:1.2.24-8.el6_6 for package: 1:dbus-1.2.24-8.el6_6.x86_64
---> Package polkit.x86_64 0:0.96-11.el6 will be installed
--> Processing Dependency: ConsoleKit for package: polkit-0.96-11.el6.x86_64
--> Processing Dependency: libeggdbus-1.so.0()(64bit) for package: polkit-0.96-11.el6.x86_64
---> Package sgml-common.noarch 0:0.6.3-33.el6 will be installed
--> Running transaction check
---> Package ConsoleKit.x86_64 0:0.4.1-3.el6 will be installed
--> Processing Dependency: libck-connector.so.0()(64bit) for package: ConsoleKit-0.4.1-3.el6.x86_64
---> Package dbus-libs.x86_64 1:1.2.24-7.el6_3 will be updated
---> Package dbus-libs.x86_64 1:1.2.24-8.el6_6 will be an update
---> Package eggdbus.x86_64 0:0.6-3.el6 will be installed
---> Package libIDL.x86_64 0:0.8.13-2.1.el6 will be installed
--> Running transaction check
---> Package ConsoleKit-libs.x86_64 0:0.4.1-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                            Arch                   Version                           Repository            Size
========================================================================================================================
Installing:
 emacs                              x86_64                 1:23.1-28.el6                     base                 2.2 M
Installing for dependencies:
 ConsoleKit                         x86_64                 0.4.1-3.el6                       base                  82 k
 ConsoleKit-libs                    x86_64                 0.4.1-3.el6                       base                  17 k
 GConf2                             x86_64                 2.28.0-6.el6                      base                 964 k
 ORBit2                             x86_64                 2.14.17-5.el6                     base                 168 k
 dbus                               x86_64                 1:1.2.24-8.el6_6                  base                 207 k
 desktop-file-utils                 x86_64                 0.15-9.el6                        base                  47 k
 eggdbus                            x86_64                 0.6-3.el6                         base                  91 k
 emacs-common                       x86_64                 1:23.1-28.el6                     base                  18 M
 giflib                             x86_64                 4.1.6-3.1.el6                     base                  37 k
 libIDL                             x86_64                 0.8.13-2.1.el6                    base                  83 k
 libXaw                             x86_64                 1.0.11-2.el6                      base                 178 k
 libXmu                             x86_64                 1.1.1-2.el6                       base                  66 k
 libXpm                             x86_64                 3.5.10-2.el6                      base                  51 k
 libXt                              x86_64                 1.1.4-6.1.el6                     base                 165 k
 libcroco                           x86_64                 0.6.2-5.el6                       base                 100 k
 libgsf                             x86_64                 1.14.15-5.el6                     base                 116 k
 libotf                             x86_64                 0.9.9-3.1.el6                     base                  80 k
 librsvg2                           x86_64                 2.26.0-14.el6                     base                 140 k
 m17n-db                            noarch                 1.5.5-1.1.el6                     base                  41 k
 m17n-db-datafiles                  noarch                 1.5.5-1.1.el6                     base                 717 k
 m17n-lib                           x86_64                 1.5.5-2.el6_1.1                   base                 157 k
 polkit                             x86_64                 0.96-11.el6                       base                 162 k
 sgml-common                        noarch                 0.6.3-33.el6                      base                  43 k
Updating for dependencies:
 dbus-libs                          x86_64                 1:1.2.24-8.el6_6                  base                 127 k

Transaction Summary
========================================================================================================================
Install      24 Package(s)
Upgrade       1 Package(s)

Total download size: 24 M
Is this ok [y/N]: y
Downloading Packages:
(1/25): ConsoleKit-0.4.1-3.el6.x86_64.rpm                                                        |  82 kB     00:00     
(2/25): ConsoleKit-libs-0.4.1-3.el6.x86_64.rpm                                                   |  17 kB     00:00     
(3/25): GConf2-2.28.0-6.el6.x86_64.rpm                                                           | 964 kB     00:00     
(4/25): ORBit2-2.14.17-5.el6.x86_64.rpm                                                          | 168 kB     00:00     
(5/25): dbus-1.2.24-8.el6_6.x86_64.rpm                                                           | 207 kB     00:00     
(6/25): dbus-libs-1.2.24-8.el6_6.x86_64.rpm                                                      | 127 kB     00:00     
(7/25): desktop-file-utils-0.15-9.el6.x86_64.rpm                                                 |  47 kB     00:00     
(8/25): eggdbus-0.6-3.el6.x86_64.rpm                                                             |  91 kB     00:00     
(9/25): emacs-23.1-28.el6.x86_64.rpm                                                             | 2.2 MB     00:01     
(10/25): emacs-common-23.1-28.el6.x86_64.rpm                                                     |  18 MB     00:18     
(11/25): giflib-4.1.6-3.1.el6.x86_64.rpm                                                         |  37 kB     00:00     
(12/25): libIDL-0.8.13-2.1.el6.x86_64.rpm                                                        |  83 kB     00:00     
(13/25): libXaw-1.0.11-2.el6.x86_64.rpm                                                          | 178 kB     00:00     
(14/25): libXmu-1.1.1-2.el6.x86_64.rpm                                                           |  66 kB     00:00     
(15/25): libXpm-3.5.10-2.el6.x86_64.rpm                                                          |  51 kB     00:00     
(16/25): libXt-1.1.4-6.1.el6.x86_64.rpm                                                          | 165 kB     00:00     
(17/25): libcroco-0.6.2-5.el6.x86_64.rpm                                                         | 100 kB     00:00     
(18/25): libgsf-1.14.15-5.el6.x86_64.rpm                                                         | 116 kB     00:00     
(19/25): libotf-0.9.9-3.1.el6.x86_64.rpm                                                         |  80 kB     00:00     
(20/25): librsvg2-2.26.0-14.el6.x86_64.rpm                                                       | 140 kB     00:00     
(21/25): m17n-db-1.5.5-1.1.el6.noarch.rpm                                                        |  41 kB     00:00     
(22/25): m17n-db-datafiles-1.5.5-1.1.el6.noarch.rpm                                              | 717 kB     00:00     
(23/25): m17n-lib-1.5.5-2.el6_1.1.x86_64.rpm                                                     | 157 kB     00:00     
(24/25): polkit-0.96-11.el6.x86_64.rpm                                                           | 162 kB     00:00     
(25/25): sgml-common-0.6.3-33.el6.noarch.rpm                                                     |  43 kB     00:00     
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   959 kB/s |  24 MB     00:25     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : 1:dbus-libs-1.2.24-8.el6_6.x86_64                                                                   1/26 
  Installing : 1:dbus-1.2.24-8.el6_6.x86_64                                                                        2/26 
  Installing : libXt-1.1.4-6.1.el6.x86_64                                                                          3/26 
  Installing : libXmu-1.1.1-2.el6.x86_64                                                                           4/26 
  Installing : m17n-db-1.5.5-1.1.el6.noarch                                                                        5/26 
  Installing : libXpm-3.5.10-2.el6.x86_64                                                                          6/26 
  Installing : libXaw-1.0.11-2.el6.x86_64                                                                          7/26 
  Installing : libotf-0.9.9-3.1.el6.x86_64                                                                         8/26 
  Installing : m17n-lib-1.5.5-2.el6_1.1.x86_64                                                                     9/26 
  Installing : m17n-db-datafiles-1.5.5-1.1.el6.noarch                                                             10/26 
  Installing : ConsoleKit-libs-0.4.1-3.el6.x86_64                                                                 11/26 
  Installing : eggdbus-0.6-3.el6.x86_64                                                                           12/26 
  Installing : polkit-0.96-11.el6.x86_64                                                                          13/26 
  Installing : ConsoleKit-0.4.1-3.el6.x86_64                                                                      14/26 
  Installing : desktop-file-utils-0.15-9.el6.x86_64                                                               15/26 
  Installing : 1:emacs-common-23.1-28.el6.x86_64                                                                  16/26 
  Installing : libcroco-0.6.2-5.el6.x86_64                                                                        17/26 
  Installing : giflib-4.1.6-3.1.el6.x86_64                                                                        18/26 
  Installing : libIDL-0.8.13-2.1.el6.x86_64                                                                       19/26 
  Installing : ORBit2-2.14.17-5.el6.x86_64                                                                        20/26 
  Installing : sgml-common-0.6.3-33.el6.noarch                                                                    21/26 
  Installing : GConf2-2.28.0-6.el6.x86_64                                                                         22/26 
  Installing : libgsf-1.14.15-5.el6.x86_64                                                                        23/26 
  Installing : librsvg2-2.26.0-14.el6.x86_64                                                                      24/26 
  Installing : 1:emacs-23.1-28.el6.x86_64                                                                         25/26 
  Cleanup    : 1:dbus-libs-1.2.24-7.el6_3.x86_64                                                                  26/26 
  Verifying  : librsvg2-2.26.0-14.el6.x86_64                                                                       1/26 
  Verifying  : sgml-common-0.6.3-33.el6.noarch                                                                     2/26 
  Verifying  : libXpm-3.5.10-2.el6.x86_64                                                                          3/26 
  Verifying  : ConsoleKit-0.4.1-3.el6.x86_64                                                                       4/26 
  Verifying  : GConf2-2.28.0-6.el6.x86_64                                                                          5/26 
  Verifying  : polkit-0.96-11.el6.x86_64                                                                           6/26 
  Verifying  : eggdbus-0.6-3.el6.x86_64                                                                            7/26 
  Verifying  : libgsf-1.14.15-5.el6.x86_64                                                                         8/26 
  Verifying  : libXt-1.1.4-6.1.el6.x86_64                                                                          9/26 
  Verifying  : ORBit2-2.14.17-5.el6.x86_64                                                                        10/26 
  Verifying  : 1:dbus-1.2.24-8.el6_6.x86_64                                                                       11/26 
  Verifying  : libIDL-0.8.13-2.1.el6.x86_64                                                                       12/26 
  Verifying  : 1:dbus-libs-1.2.24-8.el6_6.x86_64                                                                  13/26 
  Verifying  : ConsoleKit-libs-0.4.1-3.el6.x86_64                                                                 14/26 
  Verifying  : m17n-lib-1.5.5-2.el6_1.1.x86_64                                                                    15/26 
  Verifying  : libXaw-1.0.11-2.el6.x86_64                                                                         16/26 
  Verifying  : m17n-db-datafiles-1.5.5-1.1.el6.noarch                                                             17/26 
  Verifying  : libotf-0.9.9-3.1.el6.x86_64                                                                        18/26 
  Verifying  : giflib-4.1.6-3.1.el6.x86_64                                                                        19/26 
  Verifying  : libcroco-0.6.2-5.el6.x86_64                                                                        20/26 
  Verifying  : 1:emacs-23.1-28.el6.x86_64                                                                         21/26 
  Verifying  : m17n-db-1.5.5-1.1.el6.noarch                                                                       22/26 
  Verifying  : 1:emacs-common-23.1-28.el6.x86_64                                                                  23/26 
  Verifying  : libXmu-1.1.1-2.el6.x86_64                                                                          24/26 
  Verifying  : desktop-file-utils-0.15-9.el6.x86_64                                                               25/26 
  Verifying  : 1:dbus-libs-1.2.24-7.el6_3.x86_64                                                                  26/26 

Installed:
  emacs.x86_64 1:23.1-28.el6                                                                                            

Dependency Installed:
  ConsoleKit.x86_64 0:0.4.1-3.el6   ConsoleKit-libs.x86_64 0:0.4.1-3.el6       GConf2.x86_64 0:2.28.0-6.el6            
  ORBit2.x86_64 0:2.14.17-5.el6     dbus.x86_64 1:1.2.24-8.el6_6               desktop-file-utils.x86_64 0:0.15-9.el6  
  eggdbus.x86_64 0:0.6-3.el6        emacs-common.x86_64 1:23.1-28.el6          giflib.x86_64 0:4.1.6-3.1.el6           
  libIDL.x86_64 0:0.8.13-2.1.el6    libXaw.x86_64 0:1.0.11-2.el6               libXmu.x86_64 0:1.1.1-2.el6             
  libXpm.x86_64 0:3.5.10-2.el6      libXt.x86_64 0:1.1.4-6.1.el6               libcroco.x86_64 0:0.6.2-5.el6           
  libgsf.x86_64 0:1.14.15-5.el6     libotf.x86_64 0:0.9.9-3.1.el6              librsvg2.x86_64 0:2.26.0-14.el6         
  m17n-db.noarch 0:1.5.5-1.1.el6    m17n-db-datafiles.noarch 0:1.5.5-1.1.el6   m17n-lib.x86_64 0:1.5.5-2.el6_1.1       
  polkit.x86_64 0:0.96-11.el6       sgml-common.noarch 0:0.6.3-33.el6         

Dependency Updated:
  dbus-libs.x86_64 1:1.2.24-8.el6_6                                                                                     

Complete!

(3)、查看软件包组列表:grouplist

[root@soysauce test]# yum grouplist 
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Installed Groups:                        # 已安装的包组
   Additional Development
   Development tools
   E-mail server
   Emacs
   FTP server
   Graphical Administration Tools
   Legacy UNIX compatibility
   Legacy X Window System compatibility
   Load Balancer
   Milkymist
   Network file system client
   Perl Support
   Security Tools
   System administration tools
   Web Server
Available Groups:                        # 可安装的包组
   Backup Client
   Backup Server
   Base
   CIFS file server
   Client management tools
   Compatibility libraries
   Console internet tools
   Debugging Tools
   Desktop
   Desktop Debugging and Performance Tools
   Desktop Platform
   Desktop Platform Development
   Dial-up Networking Support
   Directory Client
   Directory Server
   Eclipse
   Educational Software
   Electronic Lab
   FCoE Storage Client
   Fedora Packager
   Fonts
   General Purpose Desktop
   Graphics Creation Tools
   Guest Agents
   Hardware monitoring utilities
   Haskell
   High Availability
   High Availability Management
   Identity Management Server
   Infiniband Support
   Input Methods
   Internet Applications
   Internet Browser
   Java Platform
   KDE Desktop
   Large Systems Performance
   Mainframe Access
   Messaging Client Support
   Messaging Server Support
   MySQL Database client
   MySQL Database server
   NFS file server
   Network Infrastructure Server
   Network Storage Server
   Networking Tools
   Office Suite and Productivity
   PHP Support
   Performance Tools
   PostgreSQL Database client
   PostgreSQL Database server
   Print Server
   Printing client
   Remote Desktop Clients
   Resilient Storage
   Ruby Support
   SNMP Support
   Scalable Filesystems
   Scientific support
   Server Platform
   Server Platform Development
   Smart card support
   Storage Availability Tools
   System Management
   TeX support
   Technical Writing
   TurboGears application framework
   Virtualization
   Virtualization Client
   Virtualization Platform
   Virtualization Tools
   Web Servlet Engine
   Web-Based Enterprise Management
   X Window System
   Xfce
   iSCSI Storage Client
Available Language Groups:                # 可安装的语言包组
   Afrikaans Support [af]
   Albanian Support [sq]
   Amazigh Support [ber]
   Arabic Support [ar]
   Armenian Support [hy]
   Assamese Support [as]
   Azerbaijani Support [az]
   Basque Support [eu]
   Belarusian Support [be]
   Bengali Support [bn]
   Bhutanese Support [dz]
   Brazilian Portuguese Support [pt_BR]
   Breton Support [br]
   Bulgarian Support [bg]
   Catalan Support [ca]
   Chhattisgarhi Support [hne]
   Chichewa Support [ny]
   Chinese Support [zh]
   Coptic Support [cop]
   Croatian Support [hr]
   Czech Support [cs]
   Danish Support [da]
   Dutch Support [nl]
   English (UK) Support [en_GB]
   Esperanto Support [eo]
   Estonian Support [et]
   Ethiopic Support [am]
   Faroese Support [fo]
   Fijian Support [fj]
   Filipino Support [fil]
   Finnish Support [fi]
   French Support [fr]
   Frisian Support [fy]
   Friulian Support [fur]
   Gaelic Support [gd]
   Galician Support [gl]
   Georgian Support [ka]
   German Support [de]
   Greek Support [el]
   Gujarati Support [gu]
   Hebrew Support [he]
   Hiligaynon Support [hil]
   Hindi Support [hi]
   Hungarian Support [hu]
   Icelandic Support [is]
   Indonesian Support [id]
   Interlingua Support [ia]
   Inuktitut Support [iu]
   Irish Support [ga]
   Italian Support [it]
   Japanese Support [ja]
   Kannada Support [kn]
   Kashmiri Support [ks]
   Kashubian Support [csb]
   Kazakh Support [kk]
   Khmer Support [km]
   Kinyarwanda Support [rw]
   Konkani Support [kok]
   Korean Support [ko]
   Kurdish Support [ku]
   Lao Support [lo]
   Latin Support [la]
   Latvian Support [lv]
   Lithuanian Support [lt]
   Low Saxon Support [nds]
   Luxembourgish Support [lb]
   Macedonian Support [mk]
   Maithili Support [mai]
   Malagasy Support [mg]
   Malay Support [ms]
   Malayalam Support [ml]
   Maltese Support [mt]
   Manx Support [gv]
   Maori Support [mi]
   Marathi Support [mr]
   Mongolian Support [mn]
   Myanmar (Burmese) Support [my]
   Nepali Support [ne]
   Northern Sotho Support [nso]
   Norwegian Support [nb]
   Occitan Support [oc]
   Oriya Support [or]
   Persian Support [fa]
   Polish Support [pl]
   Portuguese Support [pt]
   Punjabi Support [pa]
   Romanian Support [ro]
   Russian Support [ru]
   Sanskrit Support [sa]
   Sardinian Support [sc]
   Serbian Support [sr]
   Sindhi Support [sd]
   Sinhala Support [si]
   Slovak Support [sk]
   Slovenian Support [sl]
   Somali Support [so]
   Southern Ndebele Support [nr]
   Southern Sotho Support [st]
   Spanish Support [es]
   Swahili Support [sw]
   Swati Support [ss]
   Swedish Support [sv]
   Tagalog Support [tl]
   Tajik Support [tg]
   Tamil Support [ta]
   Telugu Support [te]
   Tetum Support [tet]
   Thai Support [th]
   Tibetan Support [bo]
   Tsonga Support [ts]
   Tswana Support [tn]
   Turkish Support [tr]
   Turkmen Support [tk]
   Ukrainian Support [uk]
   Upper Sorbian Support [hsb]
   Urdu Support [ur]
   Uzbek Support [uz]
   Venda Support [ve]
   Vietnamese Support [vi]
   Walloon Support [wa]
   Welsh Support [cy]
   Xhosa Support [xh]
   Zulu Support [zu]
Done

(4)、移除包组:groupremove

[root@soysauce test]# yum groupremove "Emacs"
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
Resolving Dependencies
--> Running transaction check
---> Package emacs.x86_64 1:23.1-28.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================
 Package                     Arch                         Version                               Repository                   Size
==================================================================================================================================
Removing:
 emacs                       x86_64                       1:23.1-28.el6                         @base                        11 M

Transaction Summary
==================================================================================================================================
Remove        1 Package(s)

Installed size: 11 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : 1:emacs-23.1-28.el6.x86_64                                                                                     1/1 
  Verifying  : 1:emacs-23.1-28.el6.x86_64                                                                                     1/1 

Removed:
  emacs.x86_64 1:23.1-28.el6                                                                                                      

Complete!



四、定义本地yum源

1、首先准备一个目录,再将软件包导入

[root@soysauce test]# ls /root/test/testyum | wc -l        # 这是我自己做测试用的,只有147个包
147

2、安装createrepo软件包

[root@soysauce test]# yum install -y createrepo  # 这是创建本地yum源的需要用软件包

3、生成yum源的元数据信息目录repodata

[root@soysauce test]# ls
testyum 
[root@soysauce test]# createrepo testyum
Spawning worker 0 with 147 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@soysauce test]# ll -d  testyum/repodata/
drwxr-xr-x 2 root root 4096 Nov 30 14:29 testyum/repodata/    # repodata目录已然生成

4、编写repo文件

[root@soysauce test]# cd /etc/yum.repos.d/        # 所有repo文件定义都在这个目录下
[root@soysauce yum.repos.d]# cat test.repo         # 新建一个以repo结尾的文件
[test]
name=test yum 
baseurl=file:///root/test/testyum
enabled=1
gpgcheck=0

5、查看yum源

[root@soysauce test]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror01.idc.hinet.net
repo id                                   repo name                                                                         status
base                                      CentOS-6 - Base - 163.com                                                          6,575
epel                                      Extra Packages for Enterprise Linux 6 - x86_64                                    11,886
extras                                    CentOS-6 - Extras - 163.com                                                           45
test                                      test yum                                                                             147        # 可以看到test源已然生效
updates                                   CentOS-6 - Updates - 163.com                                                         670
repolist: 19,323