Monday, April 29, 2024
29
rated 0 times [  29] [ 0]  / answers: 1 / hits: 9452  / 2 Years ago, wed, december 29, 2021, 8:00:26

I have added extra directories to $PATH by exporting PATH=/my/dirs:$PATH
But I am not sure if I should do the same to MANPATH. Because default MANPATH is empty yet man command works. I found a command called manpath and its manual says If $MANPATH is set, manpath will simply display its contents and issue a warning.. Does this mean setting MANPATH is not the right way to add directories for man command to search for manual pages?


More From » command-line

 Answers
3

If you simply set MANPATH, it overrides the default and you lose access to the standard man pages. For example, man ls works before setting MANPATH, but does not work afterwards.



To append a search directory without overriding the default, prefix a colon to MANPATH like this:



export MANPATH=":/path/to/custom/man"


Adding the colon gives you access to both the standard system man pages and the custom pages referenced in the MANPATH variable.



This answer brought to you by manpath(1):




If $MANPATH is set, manpath displays its value rather than
determining it on the fly. 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.



[#35098] Thursday, December 30, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
enefiama

Total Points: 43
Total Questions: 125
Total Answers: 102

Location: Gabon
Member since Sat, Jul 25, 2020
4 Years ago
enefiama questions
;