如何查询一个库文件属于哪个rpm包

1.如果这个库文件已经存在

使用rpm命令:

# rpm -qf  /file/path  (绝对路径)

例如:

# rpm -qf /lib/libm.so.6 

glibc-2.12-1.47.el6.i686

当然,这适用于rpm包已经安装了的情况。

如果,没有安装呢?比如系统提示缺少某个库?

2.如果这个库文件不存在

可以使用 

#yum provides libname

例如:

[root@blade1 gpfs1]# yum provides libm.so.6
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
glibc-2.12-1.107.el6.i686 : The GNU libc libraries
Repo        : base
Matched from:
Other       : libm.so.6
glibc-2.12-1.47.el6.i686 : The GNU libc libraries
Repo        : rhel-media
Matched from:
Other       : libm.so.6
glibc-2.12-1.47.el6.i686 : The GNU libc libraries
Repo        : installed
Matched from:
Other       : Provides-match: libm.so.6

这里查找到有三个包,可以提供libm.so.6。

如果不行,可能需要这样:

#yum provides */libname



如果OS是SuSE,需要使用命令:
zypper wp  libname

注意:libname 是要查找的库的名字。




记得要配好安装源。

原文地址:https://www.cnblogs.com/lidabo/p/3933723.html