假设您正在尝试安装特定的 deb 包,但想在实际安装之前了解该包中包含哪些文件。或者想象一下,您不确定哪个包拥有您需要的特定程序二进制文件或库。
在这些情况下,如果您可以在安装前检查特定 deb 包的内容,将会很有用。这篇文章告诉你如何去做。
在 Ubuntu 或 Debian 中,有两种方法可以在不安装特定 deb 包的情况下显示包含在特定 deb 包中的所有文件。
方法一: apt-file
第一种方法是使用apt-file
命令行工具。
要apt-file
在 Ubuntu 或 Debian 上安装和使用,请执行以下操作。
$ sudo apt-get install apt-file
$ sudo apt-file update
请注意,您首先需要运行“ apt-file update
”,以便从其来源同步所有可用的包内容。
然后要显示属于特定 deb 包(例如,tofrodos
)的文件,只需运行:
$ sudo apt-file show tofrodos
tofrodos:/usr/bin/fromdos tofrodos: /usr/bin/todos tofrodos: /usr/share/doc/tofrodos/NEWS.Debian.gz tofrodos: /usr/share/doc/tofrodos/changelog.Debian.gz tofrodos:/usr/share/doc/tofrodos/copyright tofrodos:/usr/share/doc/tofrodos/readme.txt.gz tofrodos:/usr/share/doc/tofrodos/tofrodos.html tofrodos:/usr/share/man/man1/fromdos.1.gz tofrodos:/usr/share/man/man1/todos.1.gz
输出将显示所有包含文件的名称,以及它们各自的目标安装目录。
方法二: apt-get
显示 Debian 软件包中文件的第二种方法是使用apt-get
命令,但带有--download-only
选项。
$ apt-get --download-only install tofrodos
运行上述命令后,名为 deb 的软件包tofrodos
将下载到/var/cache/apt/archives
,但不会安装。
然后你可以使用dpkg
命令列出本地下载的 deb 包的内容。
$ dpkg -c /var/cache/apt/archives/tofrodos_1.7.9.debian.1-1build1_amd64.deb
drwxr-xr-x root/root 0 2011-10-18 10:47 ./ drwxr-xr-x root/root 0 2011-10-18 10:47 ./usr/ drwxr-xr-x root/root 0 2011-10-18 10:47 ./usr/share/ drwxr-xr-x root/root 0 2011-10-18 10:47 ./usr/share/man/ drwxr-xr-x root/root 0 2011-10-18 10:47 ./usr/share/man/man1/ -rw-r--r-- root/root 1677 2011-10-18 10:47 ./usr/share/man/man1/fromdos.1.gz drwxr-xr-x root/root 0 2011-10-18 10:47 ./usr/share/doc/ drwxr-xr-x root/root 0 2011-10-18 10:47 ./usr/share/doc/tofrodos/ -rw-r--r-- root/root 391 2011-10-18 10:47 ./usr/share/doc/tofrodos/NEWS.Debian.gz -rw-r--r-- root/root 1406 2011-10-18 10:47 ./usr/share/doc/tofrodos/copyright -rw-r--r-- root/root 5832 2011-02-27 04:25 ./usr/share/doc/tofrodos/tofrodos.html -rw-r--r-- root/root 3746 2011-10-18 10:47 ./usr/share/doc/tofrodos/changelog.Debian.gz -rw-r--r-- root/root 5410 2011-02-27 04:25 ./usr/share/doc/tofrodos/readme.txt.gz drwxr-xr-x root/root 0 2011-10-18 10:47 ./usr/bin/ -rwxr-xr-x root/root 12792 2011-10-18 10:47 ./usr/bin/fromdos lrwxrwxrwx root/root 0 2011-10-18 10:47 ./usr/share/man/man1/todos.1.gz -> fromdos.1.gz lrwxrwxrwx root/root 0 2011-10-18 10:47 ./usr/bin/todos -> fromdos