If you've bothered to check, by default the environment variable MANPATH
does not exist in current versions of Ubuntu. Try this:
echo $PATH
echo $MANPATH
This is due to man
's dependence on the command manpath
. Run it from the command line, and you'll find that its output is (effectively) MANPATH, yet we already know that no variable MANPATH is defined (by default):
manpath
/usr/local/man:/usr/local/share/man:/usr/share/man
The directories where manuals reside is contained in /etc/manpath.config
, and you can edit that file to add new folders. Try this; edit /etc/manpath.config
, and then see the result by running manpath
. If that's all you need (to add some folders containing manuals), this may be a good solution for you.
In my case, I needed to also set the order in which these manual folders were searched. I found no way to set order by editing /etc/manpath.config
(please correct me if I missed that). But of course you can do that when you edit your PATH env var, and you can do the same with MANPATH as it turns out. Here are some possibilities:
- To specify MANPATH independent of
manpath
:
export MANPATH="/first/path/tomanuals:/second/path/tomanuals:etc/etc/etc"
You may get a warning from your system to the following effect:
manpath: warning: $MANPATH set, ignoring /etc/manpath.config
Which is exactly what we wanted.
- To augment
manpath
such that the folder being added is searched first:
export MANPATH="/some/dir/with/manuals/man:$(manpath)"
Of course you can change the order around to suit your needs.
- Finally if you screw up, or just want to return control to
manpath
, do this:
unset MANPATH