3

On many distributions and the BSDs there are ways to determine the number of packages in the distro's enabled repositories, e.g. on FreeBSD you could use pkg stats, is there such a way with Ubuntu? I know how to count the number of installed packages, namely using:

dpkg -l | wc -l

which on my Ubuntu 18.04 Bionic Beaver (developmental version) system returns 1962 (and yes I know not to rely on the stability of a developmental release, as things can and often do break, this is just a system for me to satisfy my curiosity about the new release to come), but how do I count all packages in its enabled repositories?

I would imagine that apt-cache search "*" would return a list of all available packages, which I could then count with wc -l but no it returns:

E: Regex compilation error

.

2 Answers 2

7

apt-cache has a function to list all packages

apt-cache pkgnames | wc -l

returns 58218 packages with main, universe, multiverse, restricted and backports enabled on artful.

3
  • Oh rofl, I thought there was a search element to it. Sorry, nvm. It works.
    – Josh Pinto
    Commented Feb 16, 2018 at 12:42
  • sudo is not required for apt-cache
    – MestreLion
    Commented Jun 4, 2023 at 7:45
  • @MestreLion thanks. Corrected. Commented Jun 6, 2023 at 16:51
1

You can use:

$ apt-cache stats
Total package names: 73411 (1.468 k)
[...]

to get that and way more information about the repositories enabled that you probably care about.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .