How to find out where $MANPATH is set?
Solution 1
As others already wrote Ubuntu doesn't set the MANPATH
by default. You can edit your .profile
and add the MANPATH
as you like. But where does Ubuntu get the information about your manpath?
This information is set in /etc/manpath.config
. The package man-db
uses this information to configure the paths for man. The environment variable MANPATH
has precedence over the file manpath.config
. The file has the following (and probably more) entries:
MANDATORY_MANPATH /usr/share/man
MANPATH_MAP /usr/bin /usr/man
DEFINE troff groff -mandoc
The first line tells a software which automatically generates the MANPATH
what directories it should contain. Typically /usr/man
, /usr/share/man
and other are set up here.
Next is a mapping from the users PATH
to the correct MANPATH
. If a user has /usr/bin
in his PATH
, the MANPATH
should contain /usr/man
in my above example.
The DEFINE
value has some default set of arguments and programs for pager utilities.
Solution 2
Ubuntu by default doesn't set $MANPATH
, so your search can be limited to your ~/.{ba,z}shrc
and the files they include
The search path compiled into the man command can be seen with man -w
. On my system (12.10), this returns /usr/local/man:/usr/local/share/man:/usr/share/man
Solution 3
Try running
zsh -x -ls -c "exit" 2> shell-startup-output
After running this command, the file shell-startup-output
should show you each file being sourced when the shell starts. You can then examine each of these files to see which one sets $MANPATH$
.
If this doesn't work for you, the only other way I know to do it is to use grep
or find
.
Related videos on Youtube
JJD
Android, Kotlin, Java, Git, Python, Ruby, Ruby on Rails, JavaScript, MacOS, Ubuntu #SOreadytohelp http://stackoverflow.com/10m
Updated on September 18, 2022Comments
-
JJD over 1 year
How can I find out in which configuration file the environment variable
$MANPATH
is set? Is there a way to backtrace the values?I am aware of that I can grep through the whole file system using
find
orgrep
. I am usingzsh
most of the time instead ofbash
. I run Ubuntu Precise. -
Andrew Johnson over 11 yearsThis should work in
bash
as well aszsh
. -
JJD over 11 yearsIt outputs the paths but not the names of the configuration files - or am I misunderstanding you?
-
JJD over 11 yearsHow do I know that Ubuntu does not set
$MANPATH
itself? -
Dennis Kaarsemaker over 11 yearsCreate a new user, log in as that user,
echo $MANPATH
. -
JJD over 11 yearsOkay. Lesson learned. Your suggestion that the configuration must be in one of the dotfiles is partially true. I found what I was looking for there. But there are configuration files also in
/etc/zsh/zshrc
. I could have manually changed those without remembering it. -
apoorva over 7 yearsIs there any way to add/append to the default search path? Or is
export MANPATH=$(man -w):/new/path
the best way?