Some time ago, a friend of mine installed FreeBSD on his old laptop and told me that it was very slow. Specially, a simple man ls took forever, while the same command on a Linux system went faster. Why was this specific command slower? Probably because he missed to install the preformatted manual pages, included in the catman series.

We'll see what these files are in a minute, but first of all you have to understand how man works. Manual pages are stored under /usr/share/man/man[1-8] (among other customizable locations). The files in these directories are the manual pages in their source code form, that is, in groff format (or some other flavour of roff, depending on the system).

Whenever you ask for a manual page, man invokes groff to generate a pretty formatted page: it indents and fills paragraphs, changes some text into boldface, etc. (As an analogy, it is like the conversion from plain HTML code to the rendered page.) When the conversion has finished, more (or the program pointed by the PAGER variable) is invoked to show you the generated page.

This process can be very slow on old systems. So, if the source pages don't change often, why not store a copy of the generated files somewhere in the system? This way, they can be accessed at will, without having to call groff. This is exactly what preformatted manual pages are for.

On a BSD system, if you look at the files stored in /usr/share/man/cat[1-8] (assuming you installed them), you'll see that they are the pretty formatted version of your manual pages. These where generated when the whole system was built, so that the conversion has to happen only once. If they are there, man will prefer them over the source pages to speed up its process.

On a Linux system, things work in a slightly different way. The preformatted pages are stored under /var/cache/man/cat[1-8], and are generated on the first read; therefore, further reads of the same manual page will be very fast. However, this only happens if the man program has the setuid bit set, or if you have enough permissions to write to that directory. Check the man(1) manual page for more information about how this works. (I'm not completely sure that this is the exact process... correct me if I'm wrong, please.)