Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 never understand what "export" does. For example, what's the difference between these two?

  1. PYTHONPATH=/home/myaccount/ & export PYTHONPATH and
  2. PYTHONPATH=/home/myaccount/

One with export and the other without.

share|improve this question
up vote 4 down vote accepted

If you don't export, then the environment variable will only be visible locally. Exporting makes them available to other programs and shells you might launch (from that shell).

share|improve this answer

"Exporting" a variable in the shell makes it available to all subshells and processes created by that shell.

It does not make it available everywhere in the system, only by processes created from that shell.

Here is an example you can try to prove the point.

("set" will list all the variables set in the terminal)

   $ ZZZ=test
   $ bash # this runs bash in bash, you can also type 'xterm' to see it work there too.
   $ set |grep ZZZ # You will not see ZZZ=test
   $ exit # Lets get out of the subshell and try export!
   $ export ZZZ
   $ bash
   $ set |grep ZZZ # and there we go! our variable is set in the subshell/process.

You can open another terminal, and see that it is not set there, however.

share|improve this answer
Thanks for your explanation and especially the example. I gave best answer to the other guy because he came a little earlier. – Shen Jul 20 '12 at 5:49

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.