सुरक्षा कारणों से, sudo
पर्यावरण चर को साफ़ कर सकते हैं यही कारण है कि यह शायद $ JAVA_HOME नहीं उठा रहा है। के /etc/sudoers
लिए अपनी फ़ाइल में देखें env_reset
।
से man sudoers
:
env_reset If set, sudo will reset the environment to only contain the following variables: HOME, LOGNAME, PATH, SHELL, TERM, and USER (in addi-
tion to the SUDO_* variables). Of these, only TERM is copied unaltered from the old environment. The other variables are set to
default values (possibly modified by the value of the set_logname option). If sudo was compiled with the SECURE_PATH option, its value
will be used for the PATH environment variable. Other variables may be preserved with the env_keep option.
env_keep Environment variables to be preserved in the user's environment when the env_reset option is in effect. This allows fine-grained con-
trol over the environment sudo-spawned processes will receive. The argument may be a double-quoted, space-separated list or a single
value without double-quotes. The list can be replaced, added to, deleted from, or disabled by using the =, +=, -=, and ! operators
respectively. This list has no default members.
इसलिए, यदि आप इसे JAVA_HOME रखना चाहते हैं, तो इसे env_keep में जोड़ें:
Defaults env_keep += "JAVA_HOME"
वैकल्पिक रूप से , JAVA_HOME
रूट में सेट करें ~/.bash_profile
।