如何查看.DEB Debian/Ubuntu软件包文件的内容

时间:2020-01-09 10:44:05  来源:igfitidea点击:

在CentOS/Fedora/RHEL下,我可以使用rpm -ql packageName命令来查看.rpm文件的联系人。
如何在Debian/Ubuntu Linux下查看.deb文件的内容?
您需要安装apt-file命令,这是一个命令行工具,用于为APT软件包管理系统搜索软件包中的文件。

安装apt文件

# apt-get update && apt-get install apt-file

输出示例:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libapt-pkg-perl libconfig-file-perl liblist-moreutils-perl menu
Suggested packages:
  gksu kdebase-bin kdebase-runtime ktsuss sux
The following NEW packages will be installed:
  apt-file libapt-pkg-perl libconfig-file-perl liblist-moreutils-perl menu
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 626kB of archives.
After this operation, 2687kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrors.kernel.org lenny/main libconfig-file-perl 1.42-1 [11.7kB]
Get:2 http://mirrors.kernel.org lenny/main libapt-pkg-perl 0.1.22+b1 [89.6kB]
Get:3 http://mirrors.kernel.org lenny/main liblist-moreutils-perl 0.22-1+b1 [51.9kB]
Get:4 http://mirrors.kernel.org lenny/main apt-file 2.1.5 [19.2kB]
Get:5 http://mirrors.kernel.org lenny/main menu 2.1.41 [453kB]                  
Fetched 626kB in 9s (67.3kB/s)                                                  
Selecting previously deselected package libconfig-file-perl.
(Reading database ... 21061 files and directories currently installed.)
Unpacking libconfig-file-perl (from .../libconfig-file-perl_1.42-1_all.deb) ...
Selecting previously deselected package libapt-pkg-perl.
Unpacking libapt-pkg-perl (from .../libapt-pkg-perl_0.1.22+b1_amd64.deb) ...
Selecting previously deselected package liblist-moreutils-perl.
Unpacking liblist-moreutils-perl (from .../liblist-moreutils-perl_0.22-1+b1_amd64.deb) ...
Selecting previously deselected package apt-file.
Unpacking apt-file (from .../apt-file_2.1.5_all.deb) ...
Selecting previously deselected package menu.
Unpacking menu (from .../archives/menu_2.1.41_amd64.deb) ...
Processing triggers for man-db ...
Setting up libconfig-file-perl (1.42-1) ...
Setting up libapt-pkg-perl (0.1.22+b1) ...
Setting up liblist-moreutils-perl (0.22-1+b1) ...
Setting up apt-file (2.1.5) ...
You need to run 'apt-file update' as root to update the cache.
Setting up menu (2.1.41) ...
Processing triggers for menu ...

首先,从源中重新同步包内容,执行:

# apt-file update

列出Debian .deb文件/软件包的内容

语法如下:

# apt-file list packageName
# apt-file list wget

输出示例:

epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/gwget.xml
epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/libgwgetextension.a
epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/libgwgetextension.la
epiphany-extension-gwget: /usr/lib/epiphany-gecko/2.22/extensions/libgwgetextension.so
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/AUTHORS
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/NEWS.gz
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/README
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/THANKS
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/TODO
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/changelog.Debian.gz
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/changelog.gz
epiphany-extension-gwget: /usr/share/doc/epiphany-extension-gwget/copyright
gwget: /usr/bin/gwget
gwget: /usr/share/applications/gwget.desktop
gwget: /usr/share/dbus-1/services/gwget.service
gwget: /usr/share/doc/gwget/AUTHORS
gwget: /usr/share/doc/gwget/NEWS.Debian.gz
.....
......
wget-el: /usr/share/emacs/site-lisp/wget-el/wget-sysdep.el
wget-el: /usr/share/emacs/site-lisp/wget-el/wget.el

如何查看foo.deb内容?

执行以下命令以查看名为foo.deb的.deb文件的内容

# dpkg-deb -c foo.deb
# dpkg-deb -c acct_6.4~pre1-6_amd64.deb

输出示例:

drwxr-xr-x root/root         0 2008-03-08 14:26 ./
drwxr-xr-x root/root         0 2008-03-08 14:26 ./etc/
drwxr-xr-x root/root         0 2008-03-08 14:26 ./etc/init.d/
-rwxr-xr-x root/root      1787 2008-03-08 14:26 ./etc/init.d/acct
drwxr-xr-x root/root         0 2008-03-08 14:26 ./etc/default/
-rw-r--r-- root/root       332 2008-03-08 14:26 ./etc/default/acct
drwxr-xr-x root/root         0 2008-03-08 14:26 ./etc/cron.monthly/
-rwxr-xr-x root/root      1281 2008-03-08 14:26 ./etc/cron.monthly/acct
drwxr-xr-x root/root         0 2008-03-08 14:26 ./etc/cron.daily/
-rwxr-xr-x root/root       379 2008-03-08 14:26 ./etc/cron.daily/acct
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/sbin/
-rwxr-xr-x root/root     11000 2008-03-08 14:26 ./usr/sbin/dump-utmp
-rwxr-xr-x root/root     12760 2008-03-08 14:26 ./usr/sbin/dump-acct
-rwxr-xr-x root/root     29240 2008-03-08 14:26 ./usr/sbin/sa
-rwxr-xr-x root/root      8184 2008-03-08 14:26 ./usr/sbin/accton
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/bin/
-rwxr-xr-x root/root     21592 2008-03-08 14:26 ./usr/bin/ac
-rwxr-xr-x root/root     20888 2008-03-08 14:26 ./usr/bin/lastcomm
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/doc-base/
-rw-r--r-- root/root       587 2008-03-08 14:26 ./usr/share/doc-base/acct
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/doc/
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/doc/acct/
-rw-r--r-- root/root      3994 2003-06-05 22:27 ./usr/share/doc/acct/README
-rw-r--r-- root/root      1247 2008-03-08 14:26 ./usr/share/doc/acct/copyright
-rw-r--r-- root/root     68845 2008-03-08 14:26 ./usr/share/doc/acct/accounting.html
-rw-r--r-- root/root      1601 2006-01-08 04:44 ./usr/share/doc/acct/NEWS.gz
-rw-r--r-- root/root      7105 2008-03-08 14:26 ./usr/share/doc/acct/changelog.Debian.gz
-rw-r--r-- root/root     14612 2006-01-08 04:44 ./usr/share/doc/acct/changelog.gz
-rw-r--r-- root/root      8534 2003-06-05 22:27 ./usr/share/doc/acct/TODO.gz
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/man/
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/man/man1/
-rw-r--r-- root/root      1655 2008-03-08 14:26 ./usr/share/man/man1/lastcomm.1.gz
-rw-r--r-- root/root      2381 2008-03-08 14:26 ./usr/share/man/man1/ac.1.gz
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/man/man8/
-rw-r--r-- root/root      3118 2008-03-08 14:26 ./usr/share/man/man8/sa.8.gz
-rw-r--r-- root/root       728 2008-03-08 14:26 ./usr/share/man/man8/dump-utmp.8.gz
-rw-r--r-- root/root       915 2008-03-08 14:26 ./usr/share/man/man8/dump-acct.8.gz
-rw-r--r-- root/root       553 2008-03-08 14:26 ./usr/share/man/man8/accton.8.gz
drwxr-xr-x root/root         0 2008-03-08 14:26 ./usr/share/info/
-rw-r--r-- root/root     11307 2008-03-08 14:26 ./usr/share/info/accounting.info.gz

您阅读已安装软件包的内容:

# dpkg -L packageName

关于apt文件列表和dpkg -L的说明

apt-file list命令列出与模式模式匹配的软件包的内容。
此操作与dpkg -L命令非常接近,只是不需要安装或者获取软件包。