Ubuntu - Root user cannot see $JAVA_HOME variable expanded to $PATH [duplicate]
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
This question already has an answer here:
Variable expansion did not happen in /etc/environment
1 answer
I have created a variable $JAVA_HOME
in `/etc/environment'
JAVA_HOME="/usr/lib/jvm/jdk"
PATH="...bla bla bla:$JAVA_HOME/bin"
I also edited /etc/profile
to have source /etc/environment
so that all users get Java home. and the directory itself has been made 755 for access.
The printout as root
for env
:
LANG=C.UTF-8
SUDO_GID=1000
USERNAME=root
JAVA_HOME=/usr/lib/jvm/jdk
SUDO_COMMAND=/bin/su
USER=root
PWD=/home/ssuser
HOME=/root
SUDO_USER=ssuser
SUDO_UID=1000
MAIL=/var/mail/root
TERM=xterm
SHELL=/bin/bash
SHLVL=2
LOGNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin
But when I do the same as ssuser
without sudo
-ing, the environment variable $JAVA_HOME
is expanded to the actual path.
SSH_CONNECTION=193.128.134.115 18497 10.1.4.4 22
LESSCLOSE=/usr/bin/lesspipe %s %s
LANG=C.UTF-8
JAVA_HOME=/usr/lib/jvm/jdk
XDG_SESSION_ID=2
USER=ssuser
PWD=/home/ssuser
HOME=/home/ssuser
SSH_CLIENT=193.128.134.115 18497 22
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
SSH_TTY=/dev/pts/0
MAIL=/var/mail/ssuser
TERM=xterm
SHELL=/bin/bash
SHLVL=1
LOGNAME=ssuser
XDG_RUNTIME_DIR=/run/user/1000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk/bin
LESSOPEN=| /usr/bin/lesspipe %s
And this has nothing to do with what's set in /etc/sudoers
for env_var reset/keep settings. Because I have tried this in a different computer and it works just fine.
I am slightly clueless as to why this is happening. Also, something very strange I have noticed is that for a single session sudo users aren't being prompted for password. I have checked /etc/sudoers
and it is set up correctly to ask password for root
.
I have tried closing the session and reopening. I can see as them as a normal user, not root. Also, rebooting doesn't do anything different.
linux ubuntu sudo environment-variables root
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 18 at 17:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
Variable expansion did not happen in /etc/environment
1 answer
I have created a variable $JAVA_HOME
in `/etc/environment'
JAVA_HOME="/usr/lib/jvm/jdk"
PATH="...bla bla bla:$JAVA_HOME/bin"
I also edited /etc/profile
to have source /etc/environment
so that all users get Java home. and the directory itself has been made 755 for access.
The printout as root
for env
:
LANG=C.UTF-8
SUDO_GID=1000
USERNAME=root
JAVA_HOME=/usr/lib/jvm/jdk
SUDO_COMMAND=/bin/su
USER=root
PWD=/home/ssuser
HOME=/root
SUDO_USER=ssuser
SUDO_UID=1000
MAIL=/var/mail/root
TERM=xterm
SHELL=/bin/bash
SHLVL=2
LOGNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin
But when I do the same as ssuser
without sudo
-ing, the environment variable $JAVA_HOME
is expanded to the actual path.
SSH_CONNECTION=193.128.134.115 18497 10.1.4.4 22
LESSCLOSE=/usr/bin/lesspipe %s %s
LANG=C.UTF-8
JAVA_HOME=/usr/lib/jvm/jdk
XDG_SESSION_ID=2
USER=ssuser
PWD=/home/ssuser
HOME=/home/ssuser
SSH_CLIENT=193.128.134.115 18497 22
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
SSH_TTY=/dev/pts/0
MAIL=/var/mail/ssuser
TERM=xterm
SHELL=/bin/bash
SHLVL=1
LOGNAME=ssuser
XDG_RUNTIME_DIR=/run/user/1000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk/bin
LESSOPEN=| /usr/bin/lesspipe %s
And this has nothing to do with what's set in /etc/sudoers
for env_var reset/keep settings. Because I have tried this in a different computer and it works just fine.
I am slightly clueless as to why this is happening. Also, something very strange I have noticed is that for a single session sudo users aren't being prompted for password. I have checked /etc/sudoers
and it is set up correctly to ask password for root
.
I have tried closing the session and reopening. I can see as them as a normal user, not root. Also, rebooting doesn't do anything different.
linux ubuntu sudo environment-variables root
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 18 at 17:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Variable expansion did not happen in /etc/environment
1 answer
I have created a variable $JAVA_HOME
in `/etc/environment'
JAVA_HOME="/usr/lib/jvm/jdk"
PATH="...bla bla bla:$JAVA_HOME/bin"
I also edited /etc/profile
to have source /etc/environment
so that all users get Java home. and the directory itself has been made 755 for access.
The printout as root
for env
:
LANG=C.UTF-8
SUDO_GID=1000
USERNAME=root
JAVA_HOME=/usr/lib/jvm/jdk
SUDO_COMMAND=/bin/su
USER=root
PWD=/home/ssuser
HOME=/root
SUDO_USER=ssuser
SUDO_UID=1000
MAIL=/var/mail/root
TERM=xterm
SHELL=/bin/bash
SHLVL=2
LOGNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin
But when I do the same as ssuser
without sudo
-ing, the environment variable $JAVA_HOME
is expanded to the actual path.
SSH_CONNECTION=193.128.134.115 18497 10.1.4.4 22
LESSCLOSE=/usr/bin/lesspipe %s %s
LANG=C.UTF-8
JAVA_HOME=/usr/lib/jvm/jdk
XDG_SESSION_ID=2
USER=ssuser
PWD=/home/ssuser
HOME=/home/ssuser
SSH_CLIENT=193.128.134.115 18497 22
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
SSH_TTY=/dev/pts/0
MAIL=/var/mail/ssuser
TERM=xterm
SHELL=/bin/bash
SHLVL=1
LOGNAME=ssuser
XDG_RUNTIME_DIR=/run/user/1000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk/bin
LESSOPEN=| /usr/bin/lesspipe %s
And this has nothing to do with what's set in /etc/sudoers
for env_var reset/keep settings. Because I have tried this in a different computer and it works just fine.
I am slightly clueless as to why this is happening. Also, something very strange I have noticed is that for a single session sudo users aren't being prompted for password. I have checked /etc/sudoers
and it is set up correctly to ask password for root
.
I have tried closing the session and reopening. I can see as them as a normal user, not root. Also, rebooting doesn't do anything different.
linux ubuntu sudo environment-variables root
This question already has an answer here:
Variable expansion did not happen in /etc/environment
1 answer
I have created a variable $JAVA_HOME
in `/etc/environment'
JAVA_HOME="/usr/lib/jvm/jdk"
PATH="...bla bla bla:$JAVA_HOME/bin"
I also edited /etc/profile
to have source /etc/environment
so that all users get Java home. and the directory itself has been made 755 for access.
The printout as root
for env
:
LANG=C.UTF-8
SUDO_GID=1000
USERNAME=root
JAVA_HOME=/usr/lib/jvm/jdk
SUDO_COMMAND=/bin/su
USER=root
PWD=/home/ssuser
HOME=/root
SUDO_USER=ssuser
SUDO_UID=1000
MAIL=/var/mail/root
TERM=xterm
SHELL=/bin/bash
SHLVL=2
LOGNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin
But when I do the same as ssuser
without sudo
-ing, the environment variable $JAVA_HOME
is expanded to the actual path.
SSH_CONNECTION=193.128.134.115 18497 10.1.4.4 22
LESSCLOSE=/usr/bin/lesspipe %s %s
LANG=C.UTF-8
JAVA_HOME=/usr/lib/jvm/jdk
XDG_SESSION_ID=2
USER=ssuser
PWD=/home/ssuser
HOME=/home/ssuser
SSH_CLIENT=193.128.134.115 18497 22
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
SSH_TTY=/dev/pts/0
MAIL=/var/mail/ssuser
TERM=xterm
SHELL=/bin/bash
SHLVL=1
LOGNAME=ssuser
XDG_RUNTIME_DIR=/run/user/1000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk/bin
LESSOPEN=| /usr/bin/lesspipe %s
And this has nothing to do with what's set in /etc/sudoers
for env_var reset/keep settings. Because I have tried this in a different computer and it works just fine.
I am slightly clueless as to why this is happening. Also, something very strange I have noticed is that for a single session sudo users aren't being prompted for password. I have checked /etc/sudoers
and it is set up correctly to ask password for root
.
I have tried closing the session and reopening. I can see as them as a normal user, not root. Also, rebooting doesn't do anything different.
This question already has an answer here:
Variable expansion did not happen in /etc/environment
1 answer
linux ubuntu sudo environment-variables root
edited Jul 19 at 14:20
slmâ¦
232k65479649
232k65479649
asked Jul 18 at 16:51
ha9u63ar
13516
13516
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 18 at 17:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Kusalananda
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Jul 18 at 17:08
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
As far as I know you don't need to put source /etc/environment
in /etc/profile
because it is not a shell script.
It should only contain key=value
pairs (without "
). Plus /etc/environment
doesn't substitute variables like $JAVA_HOME
here.
/etc/environment
gets loaded at boot so you need to reboot and it will be available for all users.
This reference has a note specifically saying variable expansion does not work in /etc/environment
:
Note: Variable expansion does not work in /etc/environment.
No it doesnt work after reboot either
â ha9u63ar
Jul 18 at 18:01
Also variable expansion does happen....it is not happening for root as i mentioned in the question ... So something else seems to be wrong here
â ha9u63ar
Jul 18 at 18:05
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As far as I know you don't need to put source /etc/environment
in /etc/profile
because it is not a shell script.
It should only contain key=value
pairs (without "
). Plus /etc/environment
doesn't substitute variables like $JAVA_HOME
here.
/etc/environment
gets loaded at boot so you need to reboot and it will be available for all users.
This reference has a note specifically saying variable expansion does not work in /etc/environment
:
Note: Variable expansion does not work in /etc/environment.
No it doesnt work after reboot either
â ha9u63ar
Jul 18 at 18:01
Also variable expansion does happen....it is not happening for root as i mentioned in the question ... So something else seems to be wrong here
â ha9u63ar
Jul 18 at 18:05
add a comment |Â
up vote
0
down vote
As far as I know you don't need to put source /etc/environment
in /etc/profile
because it is not a shell script.
It should only contain key=value
pairs (without "
). Plus /etc/environment
doesn't substitute variables like $JAVA_HOME
here.
/etc/environment
gets loaded at boot so you need to reboot and it will be available for all users.
This reference has a note specifically saying variable expansion does not work in /etc/environment
:
Note: Variable expansion does not work in /etc/environment.
No it doesnt work after reboot either
â ha9u63ar
Jul 18 at 18:01
Also variable expansion does happen....it is not happening for root as i mentioned in the question ... So something else seems to be wrong here
â ha9u63ar
Jul 18 at 18:05
add a comment |Â
up vote
0
down vote
up vote
0
down vote
As far as I know you don't need to put source /etc/environment
in /etc/profile
because it is not a shell script.
It should only contain key=value
pairs (without "
). Plus /etc/environment
doesn't substitute variables like $JAVA_HOME
here.
/etc/environment
gets loaded at boot so you need to reboot and it will be available for all users.
This reference has a note specifically saying variable expansion does not work in /etc/environment
:
Note: Variable expansion does not work in /etc/environment.
As far as I know you don't need to put source /etc/environment
in /etc/profile
because it is not a shell script.
It should only contain key=value
pairs (without "
). Plus /etc/environment
doesn't substitute variables like $JAVA_HOME
here.
/etc/environment
gets loaded at boot so you need to reboot and it will be available for all users.
This reference has a note specifically saying variable expansion does not work in /etc/environment
:
Note: Variable expansion does not work in /etc/environment.
edited Jul 19 at 14:22
slmâ¦
232k65479649
232k65479649
answered Jul 18 at 17:06
Ezwig
320212
320212
No it doesnt work after reboot either
â ha9u63ar
Jul 18 at 18:01
Also variable expansion does happen....it is not happening for root as i mentioned in the question ... So something else seems to be wrong here
â ha9u63ar
Jul 18 at 18:05
add a comment |Â
No it doesnt work after reboot either
â ha9u63ar
Jul 18 at 18:01
Also variable expansion does happen....it is not happening for root as i mentioned in the question ... So something else seems to be wrong here
â ha9u63ar
Jul 18 at 18:05
No it doesnt work after reboot either
â ha9u63ar
Jul 18 at 18:01
No it doesnt work after reboot either
â ha9u63ar
Jul 18 at 18:01
Also variable expansion does happen....it is not happening for root as i mentioned in the question ... So something else seems to be wrong here
â ha9u63ar
Jul 18 at 18:05
Also variable expansion does happen....it is not happening for root as i mentioned in the question ... So something else seems to be wrong here
â ha9u63ar
Jul 18 at 18:05
add a comment |Â