It looks like Ubuntu uses ~/.bashrc, ~/.bash_profile, ~/.pam_profile, /etc/environment, and /etc/profile in very similar ways. I’d like to be able to add a configuration to one of these (which ever is the appropriate one) to set ANT_HOME to be the absolute path to my Ant installation’s root directory (happens to be /opt/apache/ant/1.8.4/apache-ant-1.8.4/). This variable needs to be “honored” as is any normal env var, where I can open up a terminal and echo it at any time. It would also be nice if I could set this in such a way for Java to read it in at runtime from a System.getProperty("") call.
- Which file do I use?
- How do I actually set it so that it meets my requirements above?
Thanks in advance for any help or pointers here!
For global settings, system-wide environment variables
/etc/environment/etc/profile, or/etc/bash.bashrcFrom this page :
Using
/etc/profileis a very Unix-y way to go, but its functionality is greatly reduced under Ubuntu. It exists only to point to/etc/bash.bashrcand to collect entries from/etc/profile.d.On my system, the only interesting entry entry in profile.d is
/etc/profile.d/bash_completion.sh.For local or per-user settings
A previous version of the Ubuntu page recommended
~/.pam_environment, but the page currently suggests that if that doesn’t work, you should use~/.bash_profileor~./bash_login– If one of these exists, bash executes it instead of “~/.profile” when bash is started as a login shell. Bash will prefer~/.bash_profileto~/.bash_login. […] These files won’t influence a graphical session by default.”~/.bashrc– “… may be the easiest place to set variables”.