如何列出 Debian 软件包中包含的所有文件
假设您正在尝试安装特定的 deb 软件包,但想在实际安装之前了解该软件包中包含哪些文件。或者想象一下,您不确定哪个包拥有您需要的特定程序二进制文件或库。
在这些情况下,如果您能够在安装之前检查特定 deb 软件包的内容,将会非常有用。本文告诉您如何做到这一点。
在 Ubuntu 或 Debian 中,有两种方法可以显示特定 deb 软件包中包含的所有文件,而无需安装它。
方法一:apt-file
第一种方法是使用 apt-file 命令行工具。
要在 Ubuntu 或 Debian 上安装和使用 apt-file,请执行以下操作。
$ 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
运行上述命令后,名为 tofrodos
的 deb 包将被下载到 /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