How may I obtain information on a specific Debian package (.deb) file?
To get lots of information about the package use -I
or --info
:
dpkg-deb -I package.deb
dpkg-deb --info package.deb
To only get the version use, -f
or --field
:
dpkg-deb -f package.deb Version
dpkg-deb --field package.deb Version
The accepted answer is definitely the best way to do it.
If you don't have a deb based system to hand, then it can be helpful to know that a deb file is actually an ar
based archive with 3 files in it with almost fixed names. There is debian-binary, a compressed tar file called control which has meta data in it and the main package in a compressed tar file called data. The control.tar.xz file can be extracted, and the control file can be extracted from that and inspected to get the version
$ ar vt zile_2.4.14-6_amd64.deb
rw-r--r-- 0/0 4 Feb 10 11:00 2018 debian-binary
rw-r--r-- 0/0 1372 Feb 10 11:00 2018 control.tar.xz
rw-r--r-- 0/0 170540 Feb 10 11:00 2018 data.tar.xz
$ mkdir /tmp/e ; cd /tmp/e ; ar x ~-/zile_2.4.14-6_amd64.deb
$ xzcat control.tar.xz | tar vtf -
drwxr-xr-x root/root 0 2018-02-10 11:00 ./
-rw-r--r-- root/root 557 2018-02-10 11:00 ./control
-rw-r--r-- root/root 874 2018-02-10 11:00 ./md5sums
-rwxr-xr-x root/root 468 2018-02-10 11:00 ./postinst
-rwxr-xr-x root/root 167 2018-02-10 11:00 ./postrm
-rwxr-xr-x root/root 219 2018-02-10 11:00 ./prerm
$ xzcat control.tar.xz | tar xf -
$ grep Version control
Version: 2.4.14-6
$