Setting environment variables permanently.
Tom H
tomh0665 at gmail.com
Wed Mar 24 05:01:26 UTC 2010
> I am a little confused on the use of environment variables in Ubuntu. In
> windows I would simply set the variables value in the autoexec.bat file,
> and it would be available for use. I have been reading the man pages,
> and info pages for export, and env, and the following session has resulted.
> ray at RaysComputer:~$ env Test="TestValue"
> # much trimming done here to show the last line of the output.
> Test=TestValue
> ray at RaysComputer:~$ export -p Test
> ray at RaysComputer:~$ env
> # much trimming done here to show the last line of the output.
> Test=TestValue
> ray at RaysComputer:~$ echo $Test
> ray at RaysComputer:~$
> Hmmm, not persistent after the -p with export, and not persistent
> between bash sessions either. How do I set an environment variable which
> will always be available when I start a bash session, or run a bash script?
+1 to what Florian has emailed you.
AFAIK, you are misusing both env and export.
Your first env command will do nothing except possibly append
"Test=TestValue" to the output of env because it will just have been
set but not exported. It is meant to be used to set a value for an
existing environment variable, for example:
env LANG=C debootstrap ...
And "export -p" does not take a further argument. It prints out the
exported variables. So, unless the "-p" in interfering, what you have
done is the equivalent of the following commands and should output
"testValue" at the end:
$ export Test=TestValue
$ env
...
Test=TestValue
...
$ echo $Test
TestValue
More information about the ubuntu-users
mailing list