Linux rpm命令的查询模式常用方式举例

Linux大全评论1.5K views阅读模式

rpm命令的查询模式语法:

rpm {-q|--query} [select-options] [query-options]

{...}表示必选部分,[...]表示可选部分

其中:

select-options表示查询的范围,比如:按照文件查还是包查,可以是:

PACKAGE_NAME:包的名字
-a, --all:查询所有的已安装包
-f, --file FILE:查询文件FILE所属的包

-p, --package PACKAGE_FILE:查询安装包文件所在的包

按照“包的名称”查询,名称只要匹配到关键字就可以:

[irixgl@irixgl ~]$ rpm -q coreutils-
coreutils-8.5-6.fc14.i686

按照“文件所属的包”查询

[irixgl@irixgl ~]$ rpm -qf /sbin/grubby
grubby-7.0.16-1.fc14.i686

按照包文件查询

[irixgl@irixgl ~]$ rpm -qp grubby-7.0.16-1.fc13.src.rpm
warning: grubby-7.0.16-1.fc13.src.rpm: Header V3 RSA/SHA256 Signature, key ID e8e40fde: NOKEY
grubby-7.0.16-1.fc13.x86_64

上述每种方式可以叠加下面的query-options

query-options可以是:

-d, --docfiles:列出包里面的文档,用于了解man信息

-i, --info:列出包的基本信息

-l, --list:列出包里面包含的文件列表

--provides:列出包所提供的能力集
-R, --requires:列出包所依赖的能力集

查询/sbin/grubby文件所在的包的基本信息

[irixgl@irixgl ~]$ rpm -qfi /sbin/grubby
Name        : grubby                       Relocations: (not relocatable)
Version     : 7.0.16                            Vendor: Fedora Project
Release     : 1.fc14                        Build Date: Wed 14 Jul 2010 02:48:10 AM CST
Install Date: Sat 23 Oct 2010 02:16:37 AM CST      Build Host: x86-14.phx2.fedoraproject.org
Group       : System Environment/Base       Source RPM: grubby-7.0.16-1.fc14.src.rpm
Size        : 83020                            License: GPLv2+
Signature   : RSA/SHA256, Thu 29 Jul 2010 04:49:34 PM CST, Key ID 421caddb97a1071f
Packager    : Fedora Project
URL         : http://git.fedorahosted.org/git/grubby.git
Summary     : Command line tool for updating bootloader configs
Description :
grubby  is  a command line tool for updating and displaying information about
the configuration files for the grub, lilo, elilo (ia64),  yaboot (powerpc)
and zipl (s390) boot loaders. It is primarily designed to be used from scripts
which install new kernels and need to find information about the current boot

查询/sbin/grubby文件所在的包里面包含的文件

[irixgl@irixgl ~]$ rpm -qfl /sbin/grubby
/sbin/grubby
/sbin/installkernel
/sbin/new-kernel-pkg
/usr/share/doc/grubby-7.0.16
/usr/share/doc/grubby-7.0.16/COPYING
/usr/share/man/man8/grubby.8.gz
/usr/share/man/man8/installkernel.8.gz
/usr/share/man/man8/new-kernel-pkg.8.gz

查询/sbin/grubby所在的包安装后依赖的文件

[irixgl@irixgl ~]$ rpm -qfR /sbin/grubby
/bin/bash
/bin/sh
libblkid.so.1
libblkid.so.1(BLKID_1.0)
libc.so.6
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.2)
libc.so.6(GLIBC_2.3)
libc.so.6(GLIBC_2.3.4)
libc.so.6(GLIBC_2.4)
libglib-2.0.so.0
libpopt.so.0
libpopt.so.0(LIBPOPT_0)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1

格式举例:

--qf|--queryformat QUERYFMT

QUERYFMT = 用""括起来,例如""%{NAME}-%{VERSION}"

企鹅博客
  • 本文由 发表于 2019年7月16日 12:28:27
  • 转载请务必保留本文链接:https://www.qieseo.com/207178.html

发表评论