Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 or grep. I am using zsh most of the time instead of bash. I run Ubuntu Precise.

share|improve this question

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

share|improve this answer
How do I know that Ubuntu does not set $MANPATH itself? – JJD Dec 15 '12 at 20:07
Create a new user, log in as that user, echo $MANPATH. – Dennis Kaarsemaker Dec 15 '12 at 20:22
Okay. 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. – JJD Dec 15 '12 at 20:27

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.

share|improve this answer

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.

share|improve this answer
This should work in bash as well as zsh. – Andrew Johnson Dec 15 '12 at 19:02
It outputs the paths but not the names of the configuration files - or am I misunderstanding you? – JJD Dec 15 '12 at 20:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.