在RedHat,fedora和centos中支持yum,使用yum来安装软件很方便,下面是yum的使用方法:
1.yum的软件仓库(repository)
在安装yum的时候,yum会建立它的软件仓库,可以通过yum repolist来查看有哪些,yum库的定义目录为/etc/yum.repos.d,一般情况下,这些预装的库能满足我们的需要,如果自己添加repository需要相应URL和密钥。
2.列出已经安装的软件包
yum list installed 列出所有已经安装的软件包
yum list packageName 在线查看软件包
yum list installed packageName 在已经安装的软件包中查看packageName软件包,可以通过此命令来查看是否安装此软件包
如下:
[root@52 conf]# <span style="color:#ff0000">yum list sysstat</span>
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* epel: mirrors.hust.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Installed Packages
sysstat.i686 9.0.4-18.el6 @anaconda-CentOS-201112130233.i386/6.2
Available Packages
sysstat.i686 9.0.4-20.el6
[root@52 conf]# <span style="color:#ff0000">yum list installed sysstat</span>
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* epel: mirrors.hust.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Installed Packages
sysstat.i686
3.安装软件包
yum install packageName 在线安装软件包
yum localinstall packageName 安装本地rpm软件包
4.升级软件包
yum list updates 列出需要更新的软件包
yum update packageName 更新此软件包
yum update 更新所有列在yum list updates更新列表中的软件包
5.卸载软件
yum remove packageName
yum erase packageName
其中remove是只卸载软件,保留配置文件和数据文件,erase是卸载软件并删除其相关的文件。
6.查看包依赖关系
yum deplist packageName
7.查看系统中的某个文件是由哪个软件提供的
yum provides fileName
如查看httpd.conf是由哪个软件提供的配置文件
[root@52 conf]# yum provides `pwd`/httpd.conf
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* epel: mirror.neu.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
httpd-2.2.15-28.el6.centos.i686 : Apache HTTP Server
Repo : updates
Matched from:
Filename : /etc/httpd/conf/httpd.conf
httpd-2.2.15-29.el6.centos.i686 : Apache HTTP Server
Repo : updates
Matched from:
Filename : /etc/httpd/conf/httpd.conf
httpd-2.2.15-26.el6.centos.i686 : Apache HTTP Server
Repo : base
Matched from:
Filename : /etc/httpd/conf/httpd.conf
httpd-2.2.15-15.el6.centos.i686 : Apache HTTP Server
Repo : installed
Matched from:
Other : Provides-match: /etc/httpd/conf/httpd.conf
参考:http://blog.csdn.net/lichun19821101/article/details/41534593?ref=myread