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.