I'm new to using Mac OS X. From my understanding, it uses Linux under the covers. I have a need to add an environment variable. Currently, whenever I start a terminal window, I've been executing export MY_ENVIRONMENT_VARIABLE=enabled. I would like to automatically do this, system wide, when the machine starts.

How do I do that on Mac OS X? I tried adding the above line to ~/.bashrc via nano without any luck. How should I set this environment variable?

Thank you!

  • 2
    BSD, not Linux. – JdeBP May 1 '15 at 16:08

To affect system-wide settings, you probably should add:


to /etc/profile or /etc/bashrc (the latter is sourced from /etc/profile).

OSX uses bash by default for its /bin/sh. However, it does not use "Linux under the covers", but rather is mostly BSD (with some exceptions such as bash).

Here are some related questions/discussion (which suggest OSX-specific places to modify instead, e.g., environment.plist):

  • What do you mean by 'modify /etc/bashrc'. What to put there in modifications?? – IgorGanapolsky Nov 29 '15 at 16:52
  • 1
    @igor You add export MY_ENVIRONMENT_VARIABLE=enabled to /etc/profile or /etc/bashrc – wisbucky Apr 20 '16 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.