我知道如何使用rpm来列出包的内容(rpm -qpil package.rpm)。但是,这需要知道.rpm文件在文件系统中的位置。更优雅的解决方案是使用包管理器,在我的例子中是YUM。如何使用YUM来实现这一目标?
当前回答
这里有几个很好的答案,所以让我提供一个糟糕的答案:
: 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
其他回答
$ yum install -y yum-utils
$ repoquery -l packagename
百胜餐饮没有自己的套餐类型。百胜经营并帮助管理rpm。因此,您可以使用yum列出可用的rpm,然后运行rpm -qlp命令查看该包的内容。
我不认为你可以使用yum来列出包的内容,但是如果你的本地系统上有。rpm文件(对于所有安装的包来说很可能是这种情况),你可以使用rpm命令来列出该包的内容,如下所示:
rpm -qlp /path/to/fileToList.rpm
如果你没有包文件(.rpm),但你已经安装了包,试试这个:
rpm -ql packageName
有一个名为YUM -utils的包构建在YUM之上,它包含一个名为repoquery的工具,可以执行此操作。
$ repoquery --help | grep -E "list\ files"
-l, --list list files in this package/group
合并成一个例子:
$ 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
在至少一个RH系统上,使用rpm v4.8.0、yum v3.2.29和repoquery v0.0.11, repoquery -l rpm不会打印任何内容。
如果遇到这个问题,尝试添加——installed标志:repoquery——installed -l rpm。
DNF更新:
使用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
这里有几个很好的答案,所以让我提供一个糟糕的答案:
: 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
推荐文章
- fork(), vfork(), exec()和clone()的区别
- 在tmux中保持窗口名称固定
- 如何生成一个核心转储在Linux上的分段错误?
- 在Python中如何在Linux和Windows中使用“/”(目录分隔符)?
- 如何在Apache服务器上自动将HTTP重定向到HTTPS ?
- 如何限制从grep返回的结果的数量?
- 将值从管道读入shell变量
- 以相对于当前目录的路径递归地在Linux CLI中列出文件
- 如何使用xargs复制名称中有空格和引号的文件?
- 在makefile中抑制命令调用的回声?
- 在套接字编程中AF_INET和PF_INET的区别是什么?
- Chmod递归
- 任何方式退出bash脚本,但不退出终端
- 如何查看按实际内存使用情况排序的顶级进程?
- 如何将多行输出连接到一行?