Linux 如何使用 YUM 列出包的内容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/104055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to list the contents of a package using YUM?
提问by Lorin Hochstein
I know how to use rpm to list the contents of a package (rpm -qpil package.rpm
). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use the package manager, which in my case is YUM. How can YUM be used to achieve this?
我知道如何使用 rpm 列出包的内容 ( rpm -qpil package.rpm
)。但是,这需要知道 .rpm 文件在文件系统上的位置。一个更优雅的解决方案是使用包管理器,在我的例子中是 YUM。如何使用 YUM 来实现这一目标?
采纳答案by Thomas Vander Stichele
There is a package called yum-utils
that builds on YUM and contains a tool called repoquery
that can do this.
有一个yum-utils
基于 YUM 构建的包,其中包含一个repoquery
可以执行此操作的工具。
$ repoquery --help | grep -E "list\ files"
-l, --list list files in this package/group
Combined into one example:
合并为一个例子:
$ repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz
On at least one RH system, with rpm v4.8.0, yum v3.2.29, and repoquery v0.0.11, repoquery -l rpm
prints nothing.
在至少一个 RH 系统上,使用 rpm v4.8.0、yum v3.2.29 和 repoquery v0.0.11,不repoquery -l rpm
打印任何内容。
If you are having this issue, try adding the --installed
flag: repoquery --installed -l rpm
.
如果您遇到此问题,请尝试添加--installed
标志:repoquery --installed -l rpm
。
DNF
Update:
DNF
更新:
To use dnf
instead of yum-utils
, use the following command:
要使用dnf
代替yum-utils
,请使用以下命令:
$ dnf repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz
回答by Thomi
I don't think you can list the contents of a package using yum, but if you have the .rpm file on your local system (as will most likely be the case for all installed packages), you can use the rpm command to list the contents of that package like so:
我不认为您可以使用 yum 列出软件包的内容,但是如果您的本地系统上有 .rpm 文件(所有已安装的软件包很可能都是这种情况),您可以使用 rpm 命令列出该包的内容如下:
rpm -qlp /path/to/fileToList.rpm
If you don't have the package file (.rpm), but you have the package installed, try this:
如果您没有软件包文件 (.rpm),但您已经安装了软件包,请尝试以下操作:
rpm -ql packageName
回答by Haabda
Yum doesn't have it's own package type. Yum operates and helps manage RPMs. So, you can use yum to list the available RPMs and then run the rpm -qlp command to see the contents of that package.
Yum 没有自己的包类型。Yum 运营并帮助管理 RPM。因此,您可以使用 yum 列出可用的 RPM,然后运行 rpm -qlp 命令来查看该包的内容。
回答by Hüseyin Ozan TOK
$ yum install -y yum-utils
$ repoquery -l packagename
回答by Levite
rpm -ql [packageName]
Example
例子
# rpm -ql php-fpm
/etc/php-fpm.conf
/etc/php-fpm.d
/etc/php-fpm.d/www.conf
/etc/sysconfig/php-fpm
...
/run/php-fpm
/usr/lib/systemd/system/php-fpm.service
/usr/sbin/php-fpm
/usr/share/doc/php-fpm-5.6.0
/usr/share/man/man8/php-fpm.8.gz
...
/var/lib/php/sessions
/var/log/php-fpm
No need to install yum-utils, or to know the location of the rpm file.
无需安装 yum-utils,也无需知道 rpm 文件的位置。
回答by barrycarter
There are several good answers here, so let me provide a terrible one:
这里有几个很好的答案,所以让我提供一个糟糕的答案:
: you can type in anything below, doesnt have to match anything
yum whatprovides "me with a life"
: result of the above (some liberties taken with spacing):
Loaded plugins: fastestmirror
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/4): extras/7/x86_64/primary_db | 166 kB 00:00
(2/4): base/7/x86_64/group_gz | 155 kB 00:00
(3/4): updates/7/x86_64/primary_db | 9.1 MB 00:04
(4/4): base/7/x86_64/primary_db | 5.3 MB 00:05
Determining fastest mirrors
* base: mirrors.xmission.com
* extras: mirrors.xmission.com
* updates: mirrors.xmission.com
base/7/x86_64/filelists_db | 6.2 MB 00:02
extras/7/x86_64/filelists_db | 468 kB 00:00
updates/7/x86_64/filelists_db | 5.3 MB 00:01
No matches found
: the key result above is that "primary_db" files were downloaded
: filelists are downloaded EVEN IF you have keepcache=0 in your yum.conf
: note you can limit this to "primary_db.sqlite" if you really want
find /var/cache/yum -name '*.sqlite'
: if you download/install a new repo, run the exact same command again
: to get the databases for the new repo
: if you know sqlite you can stop reading here
: if not heres a sample command to dump the contents
echo 'SELECT packages.name, GROUP_CONCAT(files.name, ", ") AS files FROM files JOIN packages ON (files.pkgKey = packages.pkgKey) GROUP BY packages.name LIMIT 10;' | sqlite3 -line /var/cache/yum/x86_64/7/base/gen/primary_db.sqlite
: remove "LIMIT 10" above for the whole list
: format chosen for proof-of-concept purposes, probably can be improved a lot
回答by barrycarter
currently reopquery
is integrated into dnf
and yum
, so typing:
当前reopquery
已集成到dnf
and 中yum
,因此键入:
dnf repoquery -l <pkg-name>
will list package contents from a remote repository (even for the packages that are not installed yet)
将列出远程存储库中的包内容(即使对于尚未安装的包)
meaning installing a separate dnf-utils
or yum-utils
package is no longer required for the functionality as it is now being supported natively.
这意味着该功能不再需要安装单独的dnf-utils
或yum-utils
包,因为它现在得到了本地支持。
for listing installedor local(*.rpm
files) packages' contents there is rpm -ql
列出已安装或本地(*.rpm
文件)包的内容有rpm -ql
i don't think it is possible with yum
org dnf
(not repoquery
subcommand)
我认为yum
org dnf
(不是repoquery
子命令)是不可能的
please correct me if i am wrong
如果我错了,请纠正我