What is the best place to setup system wide environment variables on Linux?

Posted by Sorin Sbarnea on Server Fault See other posts from Server Fault or by Sorin Sbarnea
Published on 2012-03-30T13:18:11Z Indexed on 2012/03/30 17:32 UTC
Read the original article Hit count: 259

I just want to setup a system wide environment variable, JAVA_HOME for all users, including root user.

Requirements:

  • accessible to normal users
  • accessible to root
  • always loaded, not only for bash (gnome-terminal does not start a bash by default)
  • to work on Ubuntu, Debian and optionally Red Hat
  • great if addition could be easily scripted

So far here is the no-list:

  • /etc/profile.d/java.sh - not executed if you start a new console from gnome-terminal
  • /etc/profile - same as above
  • ~/.profile - current user only, also any solution assuming ~ would not be acceptable because home directory could be on NIS, and JAVA_HOME could be different.

© Server Fault or respective owner

Related posts about ubuntu

Related posts about debian