Is there any way to detect downloaded (in cache) and not installed packages using Synaptic, apt or dpkg? Do I have to create a specific filter for that? If so how do I do that? Where could I learn about that?

I know the apt or Synaptic cache is on /var/cache/apt/archives and it seems that if you install something using apt nothing goes to cache. On the other hand you have the option in Synaptic for downloading only and install later.

What I want is to know what is on that cache that is not installed already.

2 Answers 2


Quick and dirty:

PATH=/sbin:$PATH dpkg --no-act -iGE /var/cache/apt/archives/*.deb 2>&1 |grep -v skipping

This asks dpkg to pretend (--no-act) to install (-i) the packages in the cache, skipping packages for which the same version or a more recent version is already present (-GE). You don't need to be root for this, but you do need to have /sbin in your command search path because dpkg -i insists on having some utilities from /sbin in the path even though it won't use them in --no-act mode.

  • In my tests, this runs post-invoke hooks (in spite of --no-act). Jan 10, 2019 at 9:33

I don’t think you can do this with Synaptic, but here’s a command which will query the state of all the packages in the cache and list the files which don’t match an installed package:

for deb in /var/cache/apt/archives/*.deb; do
    package=$(dpkg-deb -f $deb Package)
    if [ "$(dpkg-query -f '${Status}' -W $package 2>/dev/null)" != "install ok installed" ]; then
        echo $deb

This looks at every *.deb file present in the cache, determines what package it contains, and checks the status of the package. It will list any file which corresponds to a package which isn’t fully installed and configured.

Gilles’ approach has a similar same effect, but operates en masse and ends up being substantially faster if your apt cache contains lots of packages. It has the advantage of listing upgrade candidates too, but it has the disadvantage of running certain dpkg hooks (in spite of the --no-act option).

The reason you don’t see packages in the cache after running apt (v. apg-get or Synaptic) is that apt cleans up after itself automatically.

  • Although the question doesn't explicit request it, I think it would be usually desirable to list available upgrades as well as packages that aren't installed. Jan 10, 2019 at 9:26
  • Indeed, thanks @Gilles, that’s a good point. Jan 10, 2019 at 9:33
  • This approach also doesn’t deal well with multiarch currently. Jan 10, 2019 at 9:34

You must log in to answer this question.