Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to output the name of the installed software package that owns the greatest number of system manual pages. Is there a command to do this?

share|improve this question
Interesting but strange query. Curious: What's the use case? –  Anko Sep 2 at 21:51
@Anko, it was from a Linux interview question in a site. –  Ramesh Sep 2 at 21:53
Which OS's/package manager? –  Braiam Sep 2 at 23:14
@Braiam, I was working on Cent OS. –  Ramesh Sep 2 at 23:36
If you have it, sort -V can be very helpful. It orders by versions, so there is no need to parse data, etc. –  fedorqui Sep 3 at 10:05

4 Answers 4

up vote 3 down vote accepted

On my gentoo box command

qfile /usr/share/man/*/* | awk '{print $1}' | sort | uniq -c | sort -n


    864 sys-libs/ncurses
   1139 sys-apps/man-pages-posix
   1283 dev-libs/openssl
   2209 sys-apps/man-pages
   2246 x11-libs/libxcb

But after including all subdirectories with a little help of ** pattern

qfile /usr/share/man/**/* | awk '{print $1}' | sort | uniq -c | sort -n

man-pages wins:

    933 sys-libs/ncurses
   1142 sys-apps/man-pages-posix
   1352 dev-libs/openssl
   2254 x11-libs/libxcb
   2310 sys-apps/man-pages
share|improve this answer
qfile is a gentoo only command, and while I use Gentoo also, this answer is invalid, as we should use sed or awk, so they work on all variants. –  E Carter Young Sep 2 at 21:42
You cannot use sed or awk to determine to which package file belongs, unless you want to parse package manager. That's the whole point. You must use qfile in gentoo or as others pointed out apt-file in debian or rpm in RH etc. –  jimmij Sep 2 at 21:53

For Debian-based systems, to get the package with the most installed man pages:

dpkg -S '/usr/share/man/*.gz' | cut -d: -f1 | sort | uniq -c | sort -rn | head -1 | awk '{print $2}'

To get the package with the most available man pages (whether installed or not):

apt-file search /usr/share/man | cut -d: -f1 | uniq -c | sort -rn | head -1 | awk '{print $2}'

On my system, the package with the most available man-pages is linux-manual-3.2.


Taking the pipeline used to create pkg one step at a time:

  • apt-file search /usr/share/man

    This returns the packages and file names for all files in /usr/share/man hierarchy.

  • cut -d: -f1

    This removes the file names for the list so that we just have a list of packages.

  • uniq -c

    This counts the number of man pages in each package. (Often, one needs to sort before using uniq -c but apt-find produces output one package at at time making that step unnecessary.)

  • sort -rn

    This does a numeric sort in descending order so that the package with the most man pages is at the top and those with the least are at the bottom.

  • head -1

    This picks the first line which the one with the most man pages.

  • awk '{print $2}'

    This selects the package name from that line.

I found it interesting to use just a part of this pipeline:

apt-file search /usr/share/man | cut -d: -f1 | uniq -c | sort -rn | less

This displays, via less, the list of packages sorted in descending order by number of man pages. On my system, the top five are:

   3453 linux-manual-3.2
   3384 liblapack-doc-man
   2350 freebsd-manpages
   1916 manpages-ja-dev
   1905 manpages-fr-dev
share|improve this answer
Thans for providing the information on how to find the package in debian based systems. I appreciate it. –  Ramesh Sep 2 at 20:45
Doesn't apt-file search search among all available packages? wouldn't something like dpkg -S /usr/share/man/*.gz provide an answer closer to "the name of the installed software package that ..." –  steeldriver Sep 2 at 21:42
@steeldriver Thanks. Yes, that matches the OP's intent better. Answer updated. –  John1024 Sep 2 at 22:28

Alternative for Debian/Ubuntu/Mint...

$ cd /var/lib/dpkg/info && 
  grep -c '^/usr/share/man/.*/' *.list | sort -t: -k2rn | less -XF

Gives for me:

share|improve this answer
+1 for nice use of /var/lib/dpkg/info –  John1024 Sep 2 at 23:09

This solution worked on CentOS and RHEL machines.

rpm -qf $(man -w $(compgen -ac)) | sort | uniq -c | sort -nr | head -1

I can generate the list of all the commands that are available in the system using compgen -ac. Now, man -w can tell the corresponding man page of this command.

I give this man page as input to rpm -qf which will give me the package which owns it. Now, I sort the output and then find the total occurrences and then get the first line which will give me the package name with the count of man pages corresponding to this package. After I run the above command, the output that I get is,

329 netpbm-progs-10.47.05-11.el6.x86_64

So, the above output indicates that I have 329 manual page entries for the commands provided by the package netpbm-progs-10.47.05-11.el6.x86_64 which is the highest in my system.



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.