Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I was attempting to add the man pages for my texlive distribution today when I accidentally did this:

$ MANPATH=MANPATH:/usr/local/texlive/2011/texmf/doc/man
$ export MANPATH

...when I meant this:

$ MANPATH=$MANPATH:/usr/local/texlive/2011/texmf/doc/man
$ export MANPATH

The result is that I have a very unhelpful `$MANPATH that looks like this:

$ echo $MANPATH
$ MANPATH:/usr/local/texlive/2011/texmf/doc/man

Is there a quick way of adding all man pages back into the $MANPATH?

share|improve this question
up vote 5 down vote accepted

Variables exported like that are only effective in your current shell and any child processes. If you didn't save those commands in your profile or shell-rc file, any new shells that get started up should have the original value again.

Closing your current shell and starting up a new one is the simplest way to get a meaningful set of env variables back.

share|improve this answer

If you care about your current shell session you can use the following:

MANPATH=$(source /etc/profile; echo $MANPATH)

But the most easy way might be to just start a new session, in the case you don't care about the current shell environment and variables.

Note: The above command starts a new process which reads the system wide /etc/profile (providing all the basic definitions for environment variables), and prints the "reseted" value of MANPATH. The $() construction will place the output of this process in the shell's MANPATH. Other redefinitions due to source /etc/profile won't affect the current shell, only the subprocess.

share|improve this answer
That command doesn't seem to have an effect for me. I guess I'll just restart my session :-/. – MattLBeck Aug 3 '11 at 15:06
@kikumbob: Ok, so it seems the usage of /etc/profile varies from one distribution to another. I can't tell where the default settings are on your system. – Stéphane Gimenez Aug 3 '11 at 15:28

With some man implementations, the command manpath -g shows the default system man path. If your implementation doesn't have a manpath command, check in man man what the default value is. But if you had a MANPATH variable defined, it's likely to be different from the default value.

There's no magic way to obtain the previous value of an environment variable. If you set it in this shell session, the previous setting might still be in your shell history; try searching for a previous assignment (e.g. Ctrl+R MANPATH= in bash or zsh). If the environment variable was set in some configuration file read at login time, just start a shell in another terminal and copy-paste the value from there.

share|improve this answer

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.