Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

This has been this way since 10.6. There is no .bashrc file in the home dictionary but the environment variable PATH indeed exists as the result of this command shows:

$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Anyone know how/where OS X stores environment variables?

share|improve this question
add comment

3 Answers

The system-wide default path is in /etc/paths. The default on a 10.8 system contains the following:

/usr/bin

/bin

/usr/sbin

/sbin

/usr/local/bin

To add additional system-wide PATH entries, you could change that file, but a better option would be to add a file with the additional path entries to directory /etc/paths.d. That user-created file will be protected during any upgrades/patches, which may replace a customised /etc/paths with an Apple-distributed version.

Alternatively, you could put the appropriate PATH modifying statements in /etc/profile or /etc/bashrc (in the case of bash, it will only use the latter if the former doesn't exist). Any other system-wide environment changes can be done using those files as well.

User-specific configuration can be put in $HOME/.bashrc or $HOME/.bash_profile.

Note: In the above, I've assumed you're using bash - if you're using csh or zsh, you'll need to adjust their configuration files (the information about /etc/paths and /etc/paths.d remains valid, however).

share|improve this answer
add comment

You could make your own .profile or .bashrc file to set environment variables for your user.

share|improve this answer
add comment

Where setting environmental variables for a shell which file you use is dependent on what shell you are running.

To determine what shell your running in the Terminal try:

echo $SHELL

Once you have that you can read the manual page for your shell, which is likely going to be bash.

man bash

If you are running bash, this segment from the bash manual will be helpful.

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

share|improve this answer
add comment

Your Answer

 
discard

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.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.3.10.1433\r\n            </div>\r\n                <div id=\"additional-notices\">\r\n                    Apple is a trademark of Apple Inc., registered in the US and other countries. This site is not affiliated with or endorsed by Apple Inc. in any way.\r\n                </div>\r\n  "], "copyright__copyright__copyright": ["fter reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.\n\nshare|improve this answer\nadd comment\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}