Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I'm comparing Ubuntu to other distributions for a number of factors, and for one factor I need the number of source packages, which is probably a better indicator than the total number of packages a distribution has.

It looks like I could use apt-cache dumpavail and from each section get the package name or the source name, if there is one, then get a unique count from that. But, is there an easier, faster way?

share|improve this question
Have you looked at the output of apt-cache stats? – enzotib Feb 11 '12 at 6:32
I looked at apt-cache stats, but I didn't see anything that looked like the count of source packages. – Blair Zajac Feb 11 '12 at 20:37
up vote 2 down vote accepted

You can grep the number of Package: lines in the files whose names end in _Sources in the directory /var/lib/apt/lists/:

grep '^Package: ' /var/lib/apt/lists/*_Sources | wc -l

On my Ubuntu 11.10 machine I get the number 17150.

share|improve this answer
Since I have a ppa that copies some packages from Ubuntu, I ended up using this: grep -h '^Package: ' /var/lib/apt/lists/*_Sources | sort -u | wc -l – Blair Zajac Feb 11 '12 at 22:36

Maybe you can dump the output to a text file and then using gedit , find the number of lines , the number of lines represent the number of packages. ( I assume that 1 package takes 1 line)

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.