我是从这里学的:https://www.cnblogs.com/picaso/archive/2012/07/02/2573748.html
软件的安装时操作系统管理的基础,与Windows不同,Linux的软件管理有很多种方式,Redhat的最常用的是RPM方式,安装集成在光盘中的RPM包。这种方式比Windows平台的软件管理更加便捷(个人感觉,总体感觉Windows程序安装于卸载有点复杂),使用起来也更加的心用手。
1、Redhat中的rpm包的位置—— 光盘目录中的 Package 目录全部都是。
2、RPM常用命令解读:
a、安装程序: rpm -ivh <软件包的绝对路径> #i为install;v,verbose;h,hash
[root@asdf /]# rpm -ivh /media/RHEL_6.1\ i386\ Disc\ 1/Packages/vsftpd-2.2.2-6.el6_0.1.i686.rpm
b、卸载程序: rpm -e <软件名>
[root@asdf /]# rpm -e vsftpd # e => erase 、uninstall [root@asdf /]# rpm -q vsftpd #检测一下是否已卸载 package vsftpd is not installed
rpm -aq|grep yum|xargs rpm -e --nodeps #卸载所有yum相关包
c、查询指定软件是否已安装: rpm -q <软件名> / rpm -qa <软件名> / rpm -qa | grep <软件名>
[root@asdf /]# rpm -q yum # q,query yum-3.2.29-17.el6.noarch [root@peano /]# rpm -qa yum #这个命令没有上一个命令快 yum-3.2.29-17.el6.noarch [root@peano /]# rpm -qa | grep yum #该命令使用管道进行正则匹配 yum-metadata-parser-1.1.2-16.el6.i686 PackageKit-yum-0.5.8-19.el6.i686 yum-utils-1.1.30-6.el6.noarch yum-rhn-plugin-0.9.1-26.el6.noarch PackageKit-yum-plugin-0.5.8-19.el6.i686 yum-3.2.29-17.el6.noarch
d、查询已安装软件中的某一个文件的软件包的详细名称: rpm -qf <某一文件>
[root@peano /]# rpm -qf /etc/yum.conf #qf, query file yum-3.2.29-17.el6.noarch
e、查询已安装程序都安装在哪里: rpm -ql <程序名>
[root@asdf /]# rpm -ql yum #猜测: ql,query location /etc/bash_completion.d /etc/bash_completion.d/yum.bash /etc/logrotate.d/yum /etc/yum /etc/yum.conf /etc/yum.repos.d /etc/yum/pluginconf.d /etc/yum/protected.d /etc/yum/vars /etc/yum/version-groups.conf /usr/bin/yum /usr/lib/python2.6/site-packages/rpmUtils /usr/lib/python2.6/site-packages/rpmUtils/__init__.py /usr/lib/python2.6/site-packages/rpmUtils/__init__.pyc /usr/lib/python2.6/site-packages/rpmUtils/__init__.pyo /usr/lib/python2.6/site-packages/rpmUtils/arch.py /usr/lib/python2.6/site-packages/rpmUtils/arch.pyc /usr/lib/python2.6/site-packages/rpmUtils/arch.pyo /usr/lib/python2.6/site-packages/rpmUtils/miscutils.py /usr/lib/python2.6/site-packages/rpmUtils/miscutils.pyc /usr/lib/python2.6/site-packages/rpmUtils/miscutils.pyo /usr/lib/python2.6/site-packages/rpmUtils/oldUtils.py /usr/lib/python2.6/site-packages/rpmUtils/oldUtils.pyc /usr/lib/python2.6/site-packages/rpmUtils/oldUtils.pyo /usr/lib/python2.6/site-packages/rpmUtils/transaction.py /usr/lib/python2.6/site-packages/rpmUtils/transaction.pyc /usr/lib/python2.6/site-packages/rpmUtils/transaction.pyo ---More---
f、查询已安装软件包信息: rpm -qi <软件名>
[root@asdf /]# rpm -qi yum #qi, query infomation Name : yum Relocations: (not relocatable) Version : 3.2.29 Vendor: Red Hat, Inc. Release : 17.el6 Build Date: Thu 28 Apr 2011 10:43:39 AM PDT Install Date: Mon 02 Jul 2012 02:58:17 AM PDT Build Host: x86-005.build.bos.redhat.com Group : System Environment/Base Source RPM: yum-3.2.29-17.el6.src.rpm Size : 4640583 License: GPLv2+ Signature : RSA/8, Fri 29 Apr 2011 06:41:01 AM PDT, Key ID 199e2f91fd431d51 Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> URL : http://yum.baseurl.org/ Summary : RPM package installer/updater/manager Description : Yum is a utility that can check for and automatically download and install updated RPM packages. Dependencies are obtained and downloaded automatically, prompting the user for permission as necessary. [root@asdf /]#
g、查询已安装软件的文档位置信息:rpm -qd <软件名>
[root@asdf /]# rpm -qd yum #qd, query document /usr/share/doc/yum-3.2.29/AUTHORS /usr/share/doc/yum-3.2.29/COPYING /usr/share/doc/yum-3.2.29/ChangeLog /usr/share/doc/yum-3.2.29/INSTALL /usr/share/doc/yum-3.2.29/README /usr/share/doc/yum-3.2.29/TODO /usr/share/man/man5/yum.conf.5.gz /usr/share/man/man8/yum-shell.8.gz /usr/share/man/man8/yum.8.gz [root@asdf /]#
h、查询已安装软件的依赖关系: rpm -qR <软件名>
[root@asdf /]# rpm -qR yum # qR ,query relation /usr/bin/python config(yum) = 3.2.29-17.el6 pygpgme python >= 2.4 python(abi) = 2.6 python-iniparse python-sqlite python-urlgrabber >= 3.9.0-8 rpm >= 0:4.4.2 rpm-python rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PartialHardlinkSets) <= 4.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(VersionedDependencies) <= 3.0.3-1 yum-metadata-parser >= 1.1.0 rpmlib(PayloadIsXz) <= 5.2-1
I、如果想查询未安装软件包的相关信息,可以在以上a-h的命令参数中加入一个小写的 p 即可查询相关的参数,比如h中的,查询依赖关系:
[root@asdf Packages]# rpm -qpc vsftpd-2.2.2-6.el6_0.1.i686.rpm warning: vsftpd-2.2.2-6.el6_0.1.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf [root@asdf Packages]#
J、对软件的更新操作有两种方式——rpm -Uvh 和-Fvh,两者区别在于前者在对没有安装的软件将自动安装,而后者将不安装处理;如果降级,可以采用以下命令
rpm -Uvh --oldpackage gaim-1.3.0-1.fc4.i386.rpm //新版本降级为旧版