yum rpm 常用命令使用手册

1. yum 源

直接使用yum命令实现对rpm包的搜索、安装以及yumdownloader下载rpm包,用于别的机器。

yum search package_name
yum install package_name
yumdownloader package_name

外部查找rpm包的网站:
http://rpmfind.net/
之前看到有关于yum和rpm命令文档,总结得不错,在这里贴一下,基本涵盖了日常使用的yum和rpm命令的用法。如果想要更加细致的了解,不要犹豫请man。

2. 常用yum命令

man yum 涵盖了以下的内容。

  • 2.1 Install a Package with YUM

用途:安装rpm包及其依赖

yum -y install package_name
  • 2.2 Removing a Package with YUM

用途:删除rpm包及其依赖

yum -y remove package_name
  • 2.3 Updating a Package using YUM

用途:升级rpm包

yum update package_name
  • 2.4 List a Package using YUM

用途:查看rpm包

yum list package_name
  • 2.5 Search for a Package using YUM

用途:搜索关键字rpm包

yum search package_name
  • 2.6 Get Information of a Package using YUM

用途:查看rpm包基本信息

yum info package_name
  • 2.7 List all Available Packages using YUM

用途:查看所有的rpm包

yum list | less
  • 2.8 List all Installed Packages using YUM

用途:查看所有安装了的rpm包

yum list installed | less
  • 2.9 Yum Provides Function

用途:查看哪个文件由哪个rpm提供

yum provides /etc/httpd/conf/httpd.conf
  • 2.10 Check for Available Updates using Yum

用途:检查可以升级的rpm包

yum check-update
  • 2.11 Update System using Yum

用途:升级系统的所有可升级的rpm包

yum update
  • 2.12 List all available Group Packages

用途:显示rpm包组

yum grouplist
  • 2.13 Install a Group Packages

用途:安装rpm包组

yum groupinstall 'MySQL Database'
  • 2.14 Update a Group Packages

用途:升级rpm包组

yum groupupdate 'DNS Name Server'
  • 2.15 Remove a Group Packages

用途:删除rpm包组

yum groupremove 'DNS Name Server'
  • 2.16 List Yum Repositories

用途:显示yum的仓库

yum repolist
yum repolist all
  • 2.17 Install a Package from Specific Repository

用途:使能某个软件仓库安装rpm包

yum --enablerepo=epel install phpmyadmin
  • 2.18 Interactive Yum Shell

用途:使用交互式的shell命令

# yum shell
Loaded plugins: fastestmirror
Setting up Yum Shell
> update httpd
  • 2.19 Clean Yum Cache

用途:清除yum缓存

yum clean all
  • 2.20 View History of Yum

用途:查看yum历史

yum history

3. 常用rpm命令

man rpm 涵盖以下内容。

  • 3.1 How to Check an RPM Signature Package

用途:查看rpm包是否签名

rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
  • 3.2 How to Install an RPM Package

用途:安装rpm包

 rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm

-i : install a package
-v : verbose for a nicer display
-h: print hash marks as the package archive is unpacked.
  • 3.3 How to check dependencies of RPM Package before Installing

用途:查看rpm包的依赖关系

 rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm

/usr/bin/python2.4
python >= 2.3
python(abi) = 2.4
python-crypto >= 2.0
python-psyco
python-twisted >= 2.0
python-zopeinterface
rpmlib(CompressedFileNames) = 2.6

-q : Query a package
-p : List capabilities this package provides.
-R: List capabilities on which this package depends..
  • 3.4 How to Install a RPM Package Without Dependencies

用途:忽略依赖安装rpm包

 rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm
  • 3.5 How to check an Installed RPM Package

用途:查询rpm包是否安装

 rpm -q BitTorrent
  • 3.6 How to List all files of an installed RPM package

用途:查看一个安装rpm包的所有文件

 rpm -ql BitTorrent
  • 3.7 How to List Recently Installed RPM Packages

用途:查看最新安装的rpm包

 rpm -qa --last
  • 3.8 How to List All Installed RPM Packages

用途:查看所有安装了的rpm包

 rpm -qa
  • 3.9 How to Upgrade a RPM Package

用途:升级rpm包

 rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
  • 3.10 How to Remove a RPM Package

用途:删除rpm包

rpm -evv nx
  • 3.11 How to Remove an RPM Package Without Dependencies

用途:忽略依赖删除rpm包

 rpm -ev --nodeps vsftpd
  • 3.12 How to Query a file that belongs which RPM Package

用途:查看哪个文件属于哪个rpm包

 rpm -qf /usr/bin/htpasswd
httpd-tools-2.2.15-15.el6.centos.1.i686
  • 3.13 How to Query a Information of Installed RPM Package

用途:查看安装的rpm包的基本信息

 rpm -qi vsftpd
  • 3.14 Get the Information of RPM Package Before Installing

用途:查看未安装的rpm包信息

 rpm -qip sqlbuddy-1.3.3-1.noarch.rpm
  • 3.15 How to Query documentation of Installed RPM Package

用途:查看rpm包的文档信息

 rpm -qdf /usr/bin/vmstat
/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
/usr/share/doc/procps-3.2.8/TODO
  • 3.16 How to Verify a RPM Package

用途:查看rpm包的文件是否被修改

 rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm

S.5....T.  c /etc/httpd/conf.d/sqlbuddy.conf
  • 3.17 How to Verify all RPM Packages

用途:验证所有的rpm包

 rpm -Va

S.5....T.  c /etc/rc.d/rc.local
.......T.  c /etc/dnsmasq.conf
.......T.    /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf
S.5....T.  c /etc/yum.conf
S.5....T.  c /etc/yum.repos.d/epel.repo
  • 3.18 How to Import an RPM GPG key

用途:安装GPG key

 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  • 3.19 How to List all Imported RPM GPG key

用途:查询已经安装的GPG key

 rpm -qa gpg-pubkey*
gpg-pubkey-f4a80eb5-53a7ff4b
gpg-pubkey-67431611-53bf832c
gpg-pubkey-352c64e5-52ae6884
  • 3.20 How To rebuild Corrupted RPM Database

用途:rpmdb数据库损坏重建

cd /var/lib
rm __db*
rpm --rebuilddb
 rpmdb_verify Packages

你可能感兴趣的:(Centos)