此命令只能列出已安装包的内容,
dpkg -L PACKAGENAME
Run Code Online (Sandbox Code Playgroud)
但是如何列出未安装包的内容,以预览/检查包?
小智 401
dpkg -c
(或--contents
)列出 .deb 包文件的内容(它是 . 的前端dpkg-deb
)
dpkg -c package_file.deb
Run Code Online (Sandbox Code Playgroud)
要直接使用包名称而不是包文件,您可以使用apt-file
. (您可能需要先安装apt-file
软件包。)
sudo apt-file update
apt-file list package_name
Run Code Online (Sandbox Code Playgroud)
正如第一条评论中所述,apt-file 列出了您已配置的 Apt 存储库中包的内容。是否安装了任何特定的软件包都无关紧要。
qua*_*ote 59
使用--contents
代替-L
:
dpkg --contents PACKAGENAME
Run Code Online (Sandbox Code Playgroud)
以这种方式使用时,dpkg
充当 的前端dpkg-deb
,因此用于man dpkg-deb
查看所有选项。
您还可以使用存档浏览器查看包内容。
小智 26
dpkg --contents
会让你看看卸载的包。如果 .deb 尚未在您的系统上,请执行
apt-get --download-only install pkgname
Run Code Online (Sandbox Code Playgroud)
该软件包将被下载到/var/cache/apt/archives
但未安装。
小智 17
最好的方法是直接浏览包存储库:
http://packages.debian.org/[distro name]/all/[package name]/filelist
例子:
http://packages.debian.org/wheezy/all/transmission-common/filelist
not*_*ter 10
我采用了@baldoz 的 http 想法并将其推广到 Ubuntu 和 Debian,添加了一点sed
并将其包装在 bash 函数单行中:
function deb_list () { curl -s $(lsb_release -si | sed -e 's Ubuntu https://packages.ubuntu.com ' -e 's Debian https://packages.debian.org ')/$(lsb_release -sc)/all/$1/filelist | sed -n -e '/<pre>/,/<\/pre>/p' | sed -e 's/<[^>]\+>//g' -e '/^$/d'; }
Run Code Online (Sandbox Code Playgroud)
用法:
$ deb_list curl
/usr/bin/curl
/usr/share/doc/curl/changelog.Debian.gz
/usr/share/doc/curl/copyright
/usr/share/doc/curl/NEWS.Debian.gz
/usr/share/man/man1/curl.1.gz
Run Code Online (Sandbox Code Playgroud)
多行上的相同功能:
function deb_list () {
curl -s $(lsb_release -si \
| sed -e 's Ubuntu https://packages.ubuntu.com ' \
-e 's Debian https://packages.debian.org '
)/$(lsb_release -sc)/all/$1/filelist \
| sed -n -e '/<pre>/,/<\/pre>/p' \
| sed -e 's/<[^>]\+>//g' -e '/^$/d';
}
Run Code Online (Sandbox Code Playgroud)
解释:
https://packages.ubuntu.com
或https://packages.debian.org
https://packages.ubuntu.com/trusty/all/curl/filelist
<pre>
和</pre>
标签之间的内容);第二个去掉任何 html 标签;第三个删除任何空行。注意:它不搜索 PPA、替代 apt 源代码库,只查询可用于您正在运行的 debian/ubuntu 版本的官方软件包。
对于所有可能在 2017 年 1 月仍然在谷歌搜索这个问题的人,你可以在 Debian 8.5 中使用最新版本的 apt 和 dpkg 获得一些很酷的东西,而无需下载任何东西。
无需下载即可列出 Deb 文件的内容:
首先找到 deb 文件的完整 url:
root@debian:apt-get --print-uris download yade
'http://httpredir.debian.org/debian/pool/main/y/yade/yade_2016.06a-7_amd64.deb' yade_2016.06a-7_amd64.deb 1621148 SHA256:26c0d84484a92ae9c2828edaa63243eb764378d79191149970926aa3ec40cdd4
Run Code Online (Sandbox Code Playgroud)
PS: --print-uris 开关打印 deb 包的 url 但 deb 没有下载。
然后显示 deb 包的内容而不下载它:
root@debian:curl -sL -o- "http://httpredir.debian.org/debian/pool/main/y/yade/yade_2016.06a-7_amd64.deb" |dpkg-deb -c /dev/stdin
drwxr-xr-x root/root 0 2016-12-10 22:18 ./
drwxr-xr-x root/root 0 2016-12-10 22:18 ./usr/
drwxr-xr-x root/root 0 2016-12-10 22:18 ./usr/bin/
-rwxr-xr-x root/root 13184 2016-12-10 22:18 ./usr/bin/yade
.........................more files listed bellow ......................
Run Code Online (Sandbox Code Playgroud)
PS:可以达到相同的结果
root@debian:dpkg -c <(curl -sL -o- "http://httpredir.debian.org/debian/pool/main/y/yade/yade_2016.06a-7_amd64.deb")
Run Code Online (Sandbox Code Playgroud)
从上述 deb 包中提取文件,无需下载。
例如,我们想在不安装这个包甚至不下载 deb 包的情况下阅读包 yade 的手册页。
deb 包内手册页的文件名dpkg -c
是./usr/share/man/man1/yade.1.gz
即时阅读手册页:
root@debian:curl -sL -o- "http://httpredir.debian.org/debian/pool/main/y/yade/yade_2016.06a-7_amd64.deb" |dpkg-deb --fsys-tarfile /dev/stdin |tar -xO ./usr/share/man/man1/yade.1.gz |man /dev/stdin
Run Code Online (Sandbox Code Playgroud)
使用 man 应用程序正确显示手册页。
PS:上面的管道不适用于 ar 命令。
root@debian:apt --version --> apt 1.4~beta2 (amd64)
root@debian:dpkg --version --> Debian 'dpkg' package management program version 1.18.18 (amd64).
root@debian:man --version --> man 2.7.6.1
root@debian:tar --version --> tar (GNU tar) 1.29
Run Code Online (Sandbox Code Playgroud)
小智 5
尝试:
apt-get download packages-name
dpkg --contents *.deb
Run Code Online (Sandbox Code Playgroud)