I think I understand the instructions given in How to add a directory to the PATH? about adding directories to $PATH. But I don't understand how to add directories to $MANPATH or $INFOPATH.

Also -- in googling around for help I have noticed that sometimes directions say export PATH=/usr/share/lib/something:$PATH and sometimes they say export PATH=$PATH:/usr/share/lib/something. Which is it?

4 Answers 4

  1. These 2 are almost the same:

    export PATH=/usr/share/lib/something:$PATH 
    export PATH=$PATH:/usr/share/lib/something

    The only difference is that the first one puts the directory to add in front and the second one puts it behind the current directories in $PATH. It only matters if there are commands inside /usr/share/lib/something that have the same name inside one of the directories in $PATH.

  2. To add directories to $MANPATH or $INFOPATH as required from the link you posted you do that by changing the config files inside the link.

    It says to open the global version of bash.bashrc with:

    sudo vi /etc/bash.bashrc

    and to add at the end:

    PATH=/usr/local/texlive/2010/bin/x86_64-linux:$PATH; export PATH
    MANPATH=/usr/local/texlive/2010/texmf/doc/man:$MANPATH; export MANPATH
    INFOPATH=/usr/local/texlive/2010/texmf/doc/info:$INFOPATH; export INFOPATH

    This sets $PATH, $MANPATH and $INFOPATH. And it also tells you to edit /etc/manpath.config with:

    sudo vi /etc/manpath.config

    and to add

    MANPATH_MAP /usr/local/texlive/2010/bin/x86_64-linux /usr/local/texlive/2010/texmf/doc/man

    underneath # set up PATH to MANPATH mapping.

If you are unsure about this make a backup 1st (never a bad thing) with:

sudo cp /etc/bash.bashrc /etc/bash.backup_$(date +"%Y_%m_%d").bashrc
sudo cp /etc/manpath.config /etc/manpath.backup_$(date +"%Y_%m_%d").config

The weird string changes into the current date. If you mess up just copy the backup back over the original file:

$ touch test1
$ cp test1 test1.$(date +"%Y_%m_%d")
$ ls
test1  test1.2014_11_14  
  • 1
    I installed texlive 2012 on Ubuntu Precise and echo $MANPATH returns /usr/local/texlive/2012/texmf/doc/man to me. When I add the paths to the configuration bash reports /usr/local/texlive/2012/texmf/doc/man:/usr/local/texlive/2012/texmf/doc/man and zsh still report /usr/local/texlive/2012/texmf/doc/man. For zsh I add the paths to /etc/zsh/zshrc. I am not sure if this is correct. I also tried editing /etc/environment, as suggested here, though without success.
    – JJD
    Commented Aug 16, 2012 at 23:18
  • @JJD - see also this post: Custom help / man -like command (for reminders) - Unix & Linux Stack Exchange
    – sdaau
    Commented Mar 11, 2014 at 18:42
  • What command can I see after writting MANPATH=/usr/local/texlive/2010/texmf/doc/man:$MANPATH; export MANPATH? I tried man tlmgrand it says that it doesn't exist.
    – user334407
    Commented Feb 10, 2015 at 21:29

If your man pages are in /usr/local/myproject/man, all you need to do is add that to (the end of) /etc/manpath.config:

MANDATORY_MANPATH        /usr/local/myproject/man
  • The potential problem with this answer is that it gives you no control over the order of the folders you add.
    – Seamus
    Commented Dec 19, 2023 at 5:20

x:y:z:$PATH or $PATH:x:y:z?

Barely different. $PATH contains a :-separated list of places where bash (the shell/terminal) should check for a program.

For example if you type cat the way the terminal understands what that means is to look through the first, second, third elements of $PATH, then save the first location it finds for later invocations of cat.

If I have two different versions of a program in two different places, with one of them being preferred, and $PATH tells the shell to search in the wrong order, then there's a problem. Otherwise, no problem.


Open a terminal and type

echo $a
echo a
echo $a

You'll see that a=5 set the variable value and $a refers to the variable name, not the value.

Open a second terminal and type echo $a. It should again be blank.

The difference between export and assignment (=) is explained here: https://stackoverflow.com/questions/1158091/defining-a-variable-with-or-without-export.


If you've bothered to check, by default the environment variable MANPATH does not exist in current versions of Ubuntu. Try this:

echo $PATH


This is due to man's dependence on the command manpath. Run it from the command line, and you'll find that its output is (effectively) MANPATH, yet we already know that no variable MANPATH is defined (by default):


The directories where manuals reside is contained in /etc/manpath.config, and you can edit that file to add new folders. Try this; edit /etc/manpath.config, and then see the result by running manpath. If that's all you need (to add some folders containing manuals), this may be a good solution for you.

In my case, I needed to also set the order in which these manual folders were searched. I found no way to set order by editing /etc/manpath.config (please correct me if I missed that). But of course you can do that when you edit your PATH env var, and you can do the same with MANPATH as it turns out. Here are some possibilities:

  1. To specify MANPATH independent of manpath:
export MANPATH="/first/path/tomanuals:/second/path/tomanuals:etc/etc/etc"

You may get a warning from your system to the following effect:

manpath: warning: $MANPATH set, ignoring /etc/manpath.config

Which is exactly what we wanted.

  1. To augment manpath such that the folder being added is searched first:
export MANPATH="/some/dir/with/manuals/man:$(manpath)"

Of course you can change the order around to suit your needs.

  1. Finally if you screw up, or just want to return control to manpath, do this:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .