How can I make sure an environment variable (
GRAILS_HOME for example) is set when I
I put a script in my
/etc/profile.d with this value and made it
ugo+x. What do I need to do to make this visible to the super user?
In the general case you run
Per this answer: Setting the PATH so it applies to all users, including root/sudo if you note Sudo resets all variables and path by default.
The manual page for
So, you can do the following to maintain variables when using sudo
this will open sudo settings for you. Then per what I did you add the following below
(EXCLUDING PATH as it is set by secure_path) and those are just single spaces between each variable if you wish to have more than 1 maintained.
and what this does is tell sudo which env variables to keep and not disregard.
When done hold ctrl and hit o for Write Out hit enter and say yes to save [even though it specifies a tmp file this is OK it will be written back to the main config just say yes when asked if you wish to overwrite].
That should allow you to maintain whichever variables you wish (a big one being JAVA_HOME and also http_proxy if you use a proxy).
So it should look something like below including your specified variable:
and to verify it takes exit any open terminal windows and re-open one and run
It should be what you set, now issue
and it should now remain unchanged