rpm -qf 的使用技巧,以及怎样查找软件包

首先查看安装的软件包,或者时候安装有某某软件包的命令

rpm  (-qa)| grep 软件名

root@mode oldboy]# rpm -qa| grep openssl
openssl-devel-0.9.8e-22.el5
openssl-0.9.8e-22.el5
openssl-0.9.8e-22.el5
openssl-devel-0.9.8e-22.el5
[root@mode oldboy]# yum search openssl
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
file:///mnt/cdrom/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: '/mnt/cdrom/repodata/repomd.xml'
Trying other mirror.
=============================== Matched: openssl ===============================
m2crypto.x86_64 : Support for using OpenSSL in python scripts
openssl.i686 : The OpenSSL toolkit
openssl.x86_64 : The OpenSSL toolkit
openssl-devel.i386 : Files for development of applications which will use
                   : OpenSSL
openssl-devel.x86_64 : Files for development of applications which will use
                     : OpenSSL
openssl-perl.x86_64 : Perl scripts provided with OpenSSL
openssl097a.i386 : The OpenSSL toolkit
openssl097a.x86_64 : The OpenSSL toolkit
perl-Crypt-SSLeay.x86_64 : Crypt::SSLeay - OpenSSL glue that provides LWP https
                         : support
perl-Net-SSLeay.x86_64 : Perl extension for using OpenSSL
pyOpenSSL.x86_64 : Python wrapper module around the OpenSSL library
xmlsec1.i386 : Library providing support for "XML Signature" and "XML
             : Encryption" standards
xmlsec1.x86_64 : Library providing support for "XML Signature" and "XML
               : Encryption" standards
xmlsec1-openssl.i386 : OpenSSL crypto plugin for XML Security Library
xmlsec1-openssl.x86_64 : OpenSSL crypto plugin for XML Security Library
xmlsec1-openssl-devel.i386 : OpenSSL crypto plugin for XML Security Library
xmlsec1-openssl-devel.x86_64 : OpenSSL crypto plugin for XML Security Librar


假设在生产环境中,系统的关键文件/etc/inittab被删除了(系统还没重新启动。崩溃前),不要急。以下告诉你该怎样处理。
1、模拟误删除文件
[root@localhost ~]# rm -rf /etc/inittab
[root@localhost ~]# cat /etc/inittab
cat: /etc/inittab: No such file or directory
2、新建该文件,并查看相应包的相关信息
[root@localhost ~]# touch /etc/inittab
[root@localhost ~]# rpm -qf /etc/inittab
initscripts-8.45.19.EL-1
 
3、确定了包的相关信息,挂载安装光盘,进行查找
[root@localhost ~]# cd /mnt/yum/
[root@localhost yum]# ll
total 0
[root@localhost yum]# cd ~
[root@localhost ~]# mount /dev/cdrom /mnt/yum
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/yum/Server/
[root@localhost Server]# cp initscripts-8.45.30-2.el5.i386.rpm /tmp
cp: overwrite `/tmp/initscripts-8.45.30-2.el5.i386.rpm'? y
[root@localhost Server]# cd /tmp
[root@localhost tmp]# ll
total 1680
drwx------ 2 root root    4096 Feb 17 13:45 bin
drwx------ 9 root root    4096 Feb 17 13:45 etc
drwx------ 3 root root    4096 Feb 17 13:53 gconfd-root
-r--r--r-- 1 root root 1651907 Feb 17 15:41 initscripts-8.45.30-2.el5.i386.rpm
drwx------ 2 root root    4096 Feb 17 13:53 keyring-06YG9F
drwx------ 2 root root    4096 Sep 26 08:44 keyring-elqVM1
drwx------ 2 root root    4096 Sep 26 08:08 keyring-jTNbTb
drwx------ 3 root root    4096 Feb 17 13:45 lib
srwxr-xr-x 1 root root       0 Feb 17 13:54 mapping-root
drwx------ 2 root root    4096 Feb 17 15:38 orbit-root
drwx------ 2 root root    4096 Feb 17 13:45 sbin
drwx------ 2 root root    4096 Feb 17 13:53 ssh-ROxTuK6949
drwx------ 4 root root    4096 Feb 17 13:45 usr
drwx------ 4 root root    4096 Feb 17 13:45 var
drwx------ 2 root root    4096 Feb 17 13:54 virtual-root.2eelUV
drwxrwxrwt 2 root root    4096 Feb  5 12:19 VMwareDnD
drwx------ 2 root root    4096 Feb 17 13:53 vmware-root
 
4、解压包的信息
[root@localhost tmp]# rpm2cpio initscripts-8.45.30-2.el5.i386.rpm |cpio -imd
10748 blocks
[root@localhost tmp]# ll
total 1680
drwx------ 2 root root    4096 Feb 17 13:45 bin
drwx------ 9 root root    4096 Feb 17 13:45 etc
drwx------ 3 root root    4096 Feb 17 13:53 gconfd-root
-r--r--r-- 1 root root 1651907 Feb 17 15:41 initscripts-8.45.30-2.el5.i386.rpm
drwx------ 2 root root    4096 Feb 17 13:53 keyring-06YG9F
drwx------ 2 root root    4096 Sep 26 08:44 keyring-elqVM1
drwx------ 2 root root    4096 Sep 26 08:08 keyring-jTNbTb
drwx------ 3 root root    4096 Feb 17 13:45 lib
srwxr-xr-x 1 root root       0 Feb 17 13:54 mapping-root
drwx------ 2 root root    4096 Feb 17 15:38 orbit-root
drwx------ 2 root root    4096 Feb 17 13:45 sbin
drwx------ 2 root root    4096 Feb 17 13:53 ssh-ROxTuK6949
drwx------ 4 root root    4096 Feb 17 13:45 usr
drwx------ 4 root root    4096 Feb 17 13:45 var
drwx------ 2 root root    4096 Feb 17 13:54 virtual-root.2eelUV
drwxrwxrwt 2 root root    4096 Feb  5 12:19 VMwareDnD
drwx------ 2 root root    4096 Feb 17 13:53 vmware-root
5、进行文件替换与简单改动
[root@localhost tmp]# cp ./etc/inittab /etc/
cp: overwrite `/etc/inittab'? y
[root@localhost tmp]# cat /etc/inittab
收工!!!!

。!


 yum search 软件名

rpm -qf 软件名


原文地址:https://www.cnblogs.com/yjbjingcha/p/6937012.html