转自:http://blog.csdn.net/huangbiao86/article/details/6646471
Yum配置文件位于/etc/yum.conf和/etc/yum.repos.d/CentOS-Base.repo目录下
使用yum时注意:必须使用root身份来执行yum;yum配置文件内的镜像站点必须能与自己进行网络连接;镜像站点越近,带宽越大越好,方便下载。
[root@localhost ~]# yum [options] COMMAND 软件
List of Commands:
install:Install a package or packages on your system
update:Update a package or packages on your system
remove:移出某个软件,后跟软件名称
search:Search package details for the given string 搜索某个软件或重要关键字
list:List a package or groups of packages列出yum所管理的软件名称与版本,类似于rpm –qa
info:Display details about a package or group of packages,类似于rpm –qai
clean:Remove cached data 下载文件被放置在/var/cache/yum中,可以使用clean清除。
check-update:Check for available package updates
Groupinfo:Display details about a package group
groupinstall Install the packages in a group on your system
grouplist:List available package groups
groupremove:Remove the packages in a group from your system
groupupdate:升级整个软件群组
help:Display a helpful usage message
Deplist:List a package's dependencies 列出软件包的依赖关系,在使用本地源软件包进行安装时,可以查看依赖关系
Downgrade:downgrade a package
Erase:Remove a package or packages from your system
localinstall:Install a local RPM安装本地的rpm软件包
makecache:Generate the metadata cache 生成数据缓存
provides:Find what package provides the given value 找到包提供的给定值
reinstall:reinstall a package 重装软件包
repolist:Display the configured software repositories
resolvedep:Determine which package provides the given dependency
shell:Run an interactive yum shell
upgrade:Update packages taking obsoletes into account
-y:answer yes for all questions当yum询问用户意见时,主动回答yes不需由键盘输入
-installroot=[path]:set install root安装在其他的路径,而不再当前目录树的架构中
-h --help:show this help message and exit
-t --tolerant:be tolerant of errors
-C:run entirely from cache, don't update cache
-c:[config file]config file location
-R [minutes] maximum command wait time
-d [debug level] debugging output level
-showduplicates show duplicates, in repos, in list/search commands
-e [error level] error output level
-q, --quiet quiet operation
-v, --verbose verbose operation
-version show Yum version and exit
-enablerepo=[repo] enable one or more repositories (wildcards allowed)
-disablerepo=[repo] disable one or more repositories (wildcards allowed)
-x[package], --exclude=[package]exclude package(s) by name or glob
-disableexcludes=[repo]disable exclude from main, for a repo or for everything
-obsoletes:enable obsoletes processing during updates
-noplugins:disable Yum plugins
-nogpgcheck:disable gpg signature checking
-disableplugin=[plugin] disable plugins by name
-enableplugin=[plugin] enable plugins by name
-skip-broken:skip packages with depsolving problems
-color=COLOR: control whether color is used
[root@localhost ~]# yum search gcc 查找主机上是否有gcc的相关软件,如果有,就会陈列出来。
[root@localhost ~]# yum info gcc 列出已安装的yum所管理的软件名称与版本
……………………………………………………………………
Name:gcc
Arch:i386
Version: 4.1.2
Release: 48.el5
Size:9.6 M
Repo:installed
Summary:各类编译器(C、C++、Objective-C、Java, ...)
URL:http://gcc.gnu.org
License:GPL
Description:The gcc package contains the GNU Compiler Collection version 4.1.You'll need this package in order to compile c code
……………………………………………………………………
显示该软件版本名称,数据大小,软件出处等信息。需要注意summary和description的信息
可以依据yum search 软件名查找此软件的信息,yum list软件名 列出此软件的版本和名称,决定是否安装此软件。
安装之前使用rpm –q 软件名,查看此软件是否安装,如没有安装,使用yum install 软件名 进行安装
使用yum可以主动处理好依赖关系,下载好的软件一般都放置在/var/cache/yum中,可以清除以节省磁盘空间。
[root@localhost ~]# yum clean packages #清除下载的软件包
[root@localhost ~]# yum -y update #手动系统更新