Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the Debian equivalent of Fedora's yum list installed | grep wc --lines?

share|improve this question

According to this thread:

To list installed packages:

dpkg --list | wc --lines

To see if a package is installed:

dpkg --list | grep package
share|improve this answer
You're including the header lines and some non-installed packages (e.g. rc (uninstalled but with config files left over)) in your count. – Gilles Feb 24 '11 at 23:13
dpkg -l | grep -c '^ii'

There are subtle variants like dpkg -l | grep -c '^?i' if you want to include packages that are installed but whose removal you've requested. Another way is

aptitude search '~i' |wc -l

You can even poke directly into the dpkg database:

sh -c 'set /var/lib/dpkg/info/*; echo $#'

This one includes packages that are not installed but that have configuration files left over; you can list these with dpkg -l | grep '^rc'.

share|improve this answer

dpkg -l is nice but I actually find myself using apt-show-versions (not installed by default on Debian; install the package of the same name) a lot instead, especially when I want to process the output further (dpkg tries to be too clever with line wrapping).

share|improve this answer

Synaptic, a GUI package manager, displays the count at the bottom of its main window.

enter image description here

share|improve this answer

What I've been using is:

dpkg --get-selections | wc --lines

This will give you the number of installed packages.

If you want to find if a particular package is installed, use:

dpkg --get-selections | grep <package>

I believe that this will solve Gilles' complaint about including other, non-installed packages.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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