2

when adding env varialbes like:

export JAVA_HOME=/usr/java/skd/bin

where is this stored if I want to edit it later? is it a file somewhere?

2 Answers 2

4

When you export an environment variable it is not stored in any non-volatile memory like hard disk or such. It is only remembered by shell, moreover, only in the shell you ran this command in, either by hand or with a script. So a reply to your first question may be "it is stored only in memory, local to running shell". Of course anything you will run from the shell will inherit it's environment.

If you want to change the value of environment variable, just run export again with the same variable name, like export JAVA_HOME=/usr/other_java/bin.

As the taspeotis noted, if you want the environment variable to be restored in each application launched without need of typing it manually, you can use the ~/.MacOSX/environment.plist file.

If you want it to be set only in Terminal windows, you can add the export command (as you would type it into shell) to the end of ~/.bashrc file (shell expands ~ to your home directory).

1
  • 1
    Or: if the values are only needed in Terminal, then add the export to the file ~/.bash_profile (assuming one is using the default Bash in Terminal).
    – Arjan
    Jun 6, 2010 at 12:09
1

where is this stored if I want to edit it later?

What do you mean edit it later? Export it again. It shouldn't matter where it is stored, I imagine the implementation could be shell-specific, maybe the shell performs caching of variables. Maybe it doesn't. Either way, you can read and write the environment variables in the shell so I can't imagine why you need this file.

export KEY=VALUE1

...

export KEY=VALUE2

For the record the file is ~/.MacOSX/environment.plist, as per here.

You must log in to answer this question.

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