If the MANPATH
environment variable is set, man
very "helpfully" ignores the default search path, as defined in /etc/manpath.config
. Is there any way add a path or paths to that searched by man
?
3 Answers
It depends on the man
implementation, but since you have /etc/manpath.config
I'm guessing that you're using a Debian-derived system with man-db.
In that case, manpath(1) describes what you can do here (and the same approach will work for man(1)):
If $MANPATH is prefixed by a colon, then the value of the variable is appended to the list determined from the content of the configuration files. If the colon comes at the end of the value in the variable, then the determined list is appended to the content of the variable. If the value of the variable contains a double colon (::), then the determined list is inserted in the middle of the value, between the two colons.

- 72,889

- 3,640
Depending on the particular implementation of man
, you may augment the value of MANPATH
in different ways.
On Linux systems, set MANPATH
to the value of manpath -g
:
export MANPATH="$(manpath -g):/new/path/man"
or create an alias like
alias man='man -M "$(manpath -g):/new/path/man"'
On FreeBSD, do as above, but drop the -g
.
On OpenBSD and NetBSD, use
alias man='man -m /new/path/man'
Consult the manual for the man
utility on your Unix.

- 333,661
-
-
@scrutari There is no indication in your comment how this applies to my answer. Comments are primarily for suggesting improvements to answers, but you should also be able to improve by suggesting edits directly. – Kusalananda Feb 25 '21 at 07:25
Don't set MANPATH
env variable.
You can add any number of custom paths to your local ~/.manpath
file:
MANDATORY_MANPATH /usr/local/texlive/2020/texmf-dist/doc/man
That is for a TeXlive distribution installed on /usr/local/texlive
. This file can have any number of such entries.
Also, if you have some custom /path/to/some/bin
on your PATH
, where /path/to/some/bin/..
has any of these subdirectories man
, bin/man
, share/man
, or share/man
, this man path will be added automatically (unless you prevent it by setting the MANPATH
env variable).
You can check how paths are picked up by man
by running
manpath -d

- 174

- 199
-
This is the correct answer: this way does not corrupt any global configuration, so it is the most safe one. – scrutari Feb 24 '21 at 22:09
-
2@scrutari Unfortunately, this answer does not say what Unix this applies to. Note that the question does not specify explicitly what Unix they are using. Also note that the environment variable
MANPATH
is modifiable per user, just like any environment variable, and just like the~/.manpath
file. – Kusalananda Feb 25 '21 at 07:22 -
@scrutari Setting an environment variable doesn't "corrupt any global configuration" either. – Colin Watson Feb 27 '21 at 00:22
-
I don't see any mention of
~/.manpath
in the MacOS man page forman
. Is this GNU-specific feature? – shadowtalker Jan 07 '22 at 15:53 -
I can confirm that the
~/.manpath
approach works under Bluehost's CentOS 7 (I believe that's what they're running) in shared hosting. Well done :) – Gwyneth Llewelyn May 10 '23 at 09:43 -
Grr... Why doesn't
man manpath
contain this detail? (man man
mentions it, though) – Jesse Adelman Aug 23 '23 at 20:16 -
/path:
to$MANPATH
even when it starts out empty. – muru Nov 22 '17 at 01:41MANPATH
: see answer about~/.manpath
below, – scrutari Feb 24 '21 at 22:16~/.manpath
is more flexible, but it's also that bit more complex to configure as a result of that flexibility, as compared withMANPATH
which has obvious analogies withPATH
. If all you need is to adjust the search path then I think it's perfectly reasonable to use the environment variable approach. – Colin Watson Feb 27 '21 at 00:21