Setting environment variables permanently.

Tom H tomh0665 at gmail.com
Thu Mar 25 19:14:28 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.

>>>>> 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?

>>>> Use
>>>>  export some_var=some_value
>>>> in your ~/.bashrc

>>> You could also put the line in ~/.profile. This is useful if you want
>>> the variable to be available outside of bash as well, e.g., in a
>>> graphical application launched from the menu.

>> Except that ~/.profile is not executed for a non-login shell.

> Indeed. However, any non-login shell (or other application) will inherit
> the exported variable from the login shell. Try it.

Theoretically, maybe; but

- clean install of 10.04

- added
alias dig='dig @8.8.8.8'
to
~/.profile

- rebooted

- launched gnome-terminal

- ran dig and it queried my dhcp-provided dns server




More information about the ubuntu-users mailing list