3

I know I can list the files in a package using the following command, which first download the package (.deb) into /var/cache/apt/archives and then list its contents:

apt-get --download-only install <pkg>
dpkg --contents <pkg> (.deb)

Does apt-get support any way of listing the package contents without first downloading the package?

Extra: Furthermore, how can I download a package using apt-get --download-only ... without all of its dependencies?

1
  • You can also search for some distributions on pkgs.org which will list the filenames. – meuh Jun 5 '20 at 16:51
7

I don't think that apt-get can do it, no, but apt-file can:

sudo apt install apt-file
sudo apt update

And then:

sudo apt-file list <pkg>

For example:

$ sudo apt-file list xterm
xterm: /etc/X11/app-defaults/KOI8RXTerm
xterm: /etc/X11/app-defaults/KOI8RXTerm-color
xterm: /etc/X11/app-defaults/UXTerm
xterm: /etc/X11/app-defaults/UXTerm-color
xterm: /etc/X11/app-defaults/XTerm
xterm: /etc/X11/app-defaults/XTerm-color
xterm: /usr/bin/koi8rxterm
xterm: /usr/bin/lxterm
xterm: /usr/bin/resize
xterm: /usr/bin/uxterm
xterm: /usr/bin/xterm
xterm: /usr/share/applications/debian-uxterm.desktop
xterm: /usr/share/applications/debian-xterm.desktop
xterm: /usr/share/doc-base/xterm-ctlseqs
xterm: /usr/share/doc-base/xterm-faq
xterm: /usr/share/doc/xterm/NEWS.Debian.gz
xterm: /usr/share/doc/xterm/README.Debian
xterm: /usr/share/doc/xterm/README.i18n.gz
xterm: /usr/share/doc/xterm/changelog.Debian.gz
xterm: /usr/share/doc/xterm/copyright
xterm: /usr/share/doc/xterm/ctlseqs.ms.gz
xterm: /usr/share/doc/xterm/ctlseqs.txt.gz
xterm: /usr/share/doc/xterm/xterm.faq.gz
xterm: /usr/share/doc/xterm/xterm.faq.html
xterm: /usr/share/doc/xterm/xterm.log.html
xterm: /usr/share/doc/xterm/xterm.termcap.gz
xterm: /usr/share/doc/xterm/xterm.terminfo.gz
xterm: /usr/share/icons/hicolor/48x48/apps/xterm-color.png
xterm: /usr/share/icons/hicolor/scalable/apps/xterm-color.svg
xterm: /usr/share/man/man1/koi8rxterm.1.gz
xterm: /usr/share/man/man1/lxterm.1.gz
xterm: /usr/share/man/man1/resize.1.gz
xterm: /usr/share/man/man1/uxterm.1.gz
xterm: /usr/share/man/man1/xterm.1.gz
xterm: /usr/share/pixmaps/filled-xterm_32x32.xpm
xterm: /usr/share/pixmaps/filled-xterm_48x48.xpm
xterm: /usr/share/pixmaps/mini.xterm_32x32.xpm
xterm: /usr/share/pixmaps/mini.xterm_48x48.xpm
xterm: /usr/share/pixmaps/xterm-color_32x32.xpm
xterm: /usr/share/pixmaps/xterm-color_48x48.xpm
xterm: /usr/share/pixmaps/xterm_32x32.xpm
xterm: /usr/share/pixmaps/xterm_48x48.xpm

As for downloading, that's what the download command is for:

apt-get download <pkg>

See man apt-get:

   download
       download will download the given binary package into the current
       directory.
3
  • Thank you, @terdon. Do you know how apt-file works? Does it download the package locally before running dpkg --contents, or does it consult some online resource? Is it developed by the developers of APT or someone else? – Shuzheng Jun 5 '20 at 17:47
  • why would I use apt-get --download-only install, when apt-get download is available? Is it only because the former will also download dependencies (and put them all in /var/cache/apt/archives), while the latter will only download the specified package without dependencies into the current directory? – Shuzheng Jun 5 '20 at 17:50
  • 2
    apt-file works by downloading a Contents file from the Debian/Ubuntu/etc. repository. – Daniel Schepler Jun 6 '20 at 2:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.