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
    
So I can store the long uri of my computer lab in a variable –  mko Jul 27 '12 at 11:23
1  
You can easily create a .bashrc in your home folder yourself, can't you? –  patrix Jul 27 '12 at 11:51
add comment

3 Answers 3

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
    
On OS X, .bash_profile is indeed the correct name for the configuration file. –  cksum Jul 27 '12 at 15:11
    
.bashrc is still used for non-login interactive shells (see the manual page for more information). –  mjturner Jul 28 '12 at 15:15
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.