歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux rpm命令的查詢模式常用方式舉例

Linux rpm命令的查詢模式常用方式舉例

日期:2017/2/28 16:16:50   编辑:Linux教程

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}"

文件解包:

rpm2cpio xxx.rpm | cpio -idmv

Copyright © Linux教程網 All Rights Reserved