What is the best place to setup system wide environment variables on Linux?
For Ubuntu, and possibly other *nix platforms, add a new script in /etc/profile.d
named java.sh
, such as:
echo "export JAVA_HOME=/usr/lib/jvm/default-java" > /etc/profile.d/java.sh
Other considerations that were ruled out:
-
/etc/environment
- works but is harder to maintain using other tools (or people will edit it); and -
/etc/profile
- same drawbacks as/etc/environment
On Debian/Ubuntu that would be /etc/environment
I don't know the Red Hat equivalent.