[技巧] 如何查看Debian/Ubuntu软件包.deb的内容

在Redhat系Linux版本(CentOS/Fedora/RHEL)下,我们想要查看rpm包的内容,直接使用 rpm -ql packagename 命令就可以了,那么在Debian/Ubuntu Linux下又如何查看.deb软件包的内容呢?

系统默认安装的软件和命令无法查看,这时候我们需要安装 apt-file 命令工具,该命令可以查看使用APT作为软件包管理器的系统deb文件的内容。

安装apt-file
  1. #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查看deb包内容前,我们首先得重新同步一下软件包内容。
  1. #apt-file update
列出Debian下.deb文件或软件包的内容

命令格式如下:
  1. #apt-file list packageName
下面我们以wget为例,来看看其中包含的文件列表:
  1. #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文件的内容:
  1. #dpkg-deb -c foo.deb
  2. #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命令就能查看:
  1. #dpkg -L packageName
转载请注明出处: http://club.topsage.com/thread-2208923-1-1.html

你可能感兴趣的:([技巧] 如何查看Debian/Ubuntu软件包.deb的内容)