rpm命令

用CentOS也有一段时间了,整理一下rpm命令的用法

安装.rpm的文件,-i代表–install,-v代表–verbose,-h代表–hash 以#显示安装进度

rpm -ivh package.rpm

升级软件包

rpm -U packupdate.rpm

查看已经安装的软件

列出已经安装的全部软件包,查具体包可接 | grep 来筛选,或使用通配符

rpm -qa

例如:

# rpm -qa httpd* 
httpd-tools-2.2.15-15.el6.centos.1.x86_64
httpd-2.2.15-15.el6.centos.1.x86_64
或
# rpm -qa | grep http
httpd-tools-2.2.15-15.el6.centos.1.x86_64
httpd-2.2.15-15.el6.centos.1.x86_64

找到某文件属于哪个软件包,使用

rpm -qf filename

例如:

rpm -qf /etc/httpd/conf/httpd.conf

执行结果: httpd-2.2.15-15.el6.centos.1.x86_64

-qi 查看已经安装的软件包的功能,

rpm -qi packagename

-pqi 查看没有安装的.rpm包的详细信息

[root@localhost ~]# rpm -pqi epel-release-6-8.noarch.rpm 
Name        : epel-release                 Relocations: (not relocatable)
Version     : 6                                 Vendor: Fedora Project
Release     : 8                             Build Date: Mon 05 Nov 2012 11:54:41 AM CST
Install Date: (not installed)               Build Host: buildvm-05.phx2.fedoraproject.org
Group       : System Environment/Base       Source RPM: epel-release-6-8.src.rpm
Size        : 22169                            License: GPLv2
Signature   : RSA/8, Mon 05 Nov 2012 11:29:49 PM CST, Key ID 3b49df2a0608b895
Packager    : Fedora Project
URL         : http://dl.fedoraproject.org/pub/epel/
Summary     : Extra Packages for Enterprise Linux repository configuration
Description :
This package contains the Extra Packages for Enterprise Linux (EPEL) repository
GPG key as well as configuration for yum and up2date.

如查看wget的功能说明

rpm -qi wget

删除已经安装的软件包

rpm -e packagename

查看已经安装好的软件包都包含哪些文件

rpm -ql iptables

查看某个 rpm 包包含有哪些文件

rpm -qlp package.rpm

对于 yum 源里没有安装在本机的 rpm 包查看要装哪些文件,可以这样查(前提要安装好yum-utils)

repoquery -q -l --plugins memcached

参考:http://www.cyberciti.biz/faq/howto-list-find-files-in-rpm-package/

发表评论

电子邮件地址不会被公开。 必填项已用*标注