0

On Debian/Ubuntu, dpkg can show me packages, include the version and what's installed (e.g. dpkg -l postgresql\*). But that shows all packages that it knows about, whether installed or not.

Is it possible to make dpkg only show me the installed packages?

I've tried on dpkg v1.21.8 on Debian testing/bookworm, and v1.19.0.5 on Ubuntu 18.04 bionic

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246
  • 3
    According to the man page `dpkg -l` **does** only show installed packages (and packages with residual config). I can confirm this behaviour on my Ubuntu 18.04 and 20.04 machines. – Gerald Schneider Jun 28 '22 at 11:22

1 Answers1

1

dpkg itself cannot do it, but it's possible to achieve it with a combination of dpkg-query and awk:

dpkg-query -W -f '${db:Status-Status} ${Package}\n' 'linux-image-[0-9]*' | awk '$1 != "not-installed" {print}'

See this question over on Ask Ubuntu: https://askubuntu.com/questions/1330078/limit-output-of-dpkg-query-w-to-installed-packages

Tilman Schmidt
  • 3,778
  • 10
  • 23