Which is not searching full $PATH

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
If I run sudo which abc I would expect it to search the superusers $PATH for the program 'abc', but it looks like it only searches a subset.
I can see this by running sudo echo $PATH and comparing the paths searched.
$ sudo which abc
which: no abc in (/sbin:/bin:/usr/sbin:/usr/bin)
$ sudo echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
What is happening here?
bash sudo path which
add a comment |Â
up vote
0
down vote
favorite
If I run sudo which abc I would expect it to search the superusers $PATH for the program 'abc', but it looks like it only searches a subset.
I can see this by running sudo echo $PATH and comparing the paths searched.
$ sudo which abc
which: no abc in (/sbin:/bin:/usr/sbin:/usr/bin)
$ sudo echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
What is happening here?
bash sudo path which
And where isabcactually located ?
â steve
Jul 28 at 10:50
2
Note thatsudo echo $PATHwill not show root's $PATH. gets resolved by current she'll and then passed to sudo....
â steve
Jul 28 at 10:52
1
Also note that if you use sudo to actually executeabc, it is typically configured to search its ownsecure_pathrather than the root user'sPATH. Seeman sudoers.
â steeldriver
Jul 28 at 11:25
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
If I run sudo which abc I would expect it to search the superusers $PATH for the program 'abc', but it looks like it only searches a subset.
I can see this by running sudo echo $PATH and comparing the paths searched.
$ sudo which abc
which: no abc in (/sbin:/bin:/usr/sbin:/usr/bin)
$ sudo echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
What is happening here?
bash sudo path which
If I run sudo which abc I would expect it to search the superusers $PATH for the program 'abc', but it looks like it only searches a subset.
I can see this by running sudo echo $PATH and comparing the paths searched.
$ sudo which abc
which: no abc in (/sbin:/bin:/usr/sbin:/usr/bin)
$ sudo echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
What is happening here?
bash sudo path which
edited Jul 28 at 11:57
ctrl-alt-delor
8,54031946
8,54031946
asked Jul 28 at 10:46
Jethro
1033
1033
And where isabcactually located ?
â steve
Jul 28 at 10:50
2
Note thatsudo echo $PATHwill not show root's $PATH. gets resolved by current she'll and then passed to sudo....
â steve
Jul 28 at 10:52
1
Also note that if you use sudo to actually executeabc, it is typically configured to search its ownsecure_pathrather than the root user'sPATH. Seeman sudoers.
â steeldriver
Jul 28 at 11:25
add a comment |Â
And where isabcactually located ?
â steve
Jul 28 at 10:50
2
Note thatsudo echo $PATHwill not show root's $PATH. gets resolved by current she'll and then passed to sudo....
â steve
Jul 28 at 10:52
1
Also note that if you use sudo to actually executeabc, it is typically configured to search its ownsecure_pathrather than the root user'sPATH. Seeman sudoers.
â steeldriver
Jul 28 at 11:25
And where is
abc actually located ?â steve
Jul 28 at 10:50
And where is
abc actually located ?â steve
Jul 28 at 10:50
2
2
Note that
sudo echo $PATH will not show root's $PATH. gets resolved by current she'll and then passed to sudo....â steve
Jul 28 at 10:52
Note that
sudo echo $PATH will not show root's $PATH. gets resolved by current she'll and then passed to sudo....â steve
Jul 28 at 10:52
1
1
Also note that if you use sudo to actually execute
abc, it is typically configured to search its own secure_path rather than the root user's PATH. See man sudoers.â steeldriver
Jul 28 at 11:25
Also note that if you use sudo to actually execute
abc, it is typically configured to search its own secure_path rather than the root user's PATH. See man sudoers.â steeldriver
Jul 28 at 11:25
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
$PATH is expanded before sudo is run. Therefore you are seeing the value of PATH for you, and not for the user you sudo to.
try this instead:
$ sudo bash -c 'echo $PATH'
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
$PATH is expanded before sudo is run. Therefore you are seeing the value of PATH for you, and not for the user you sudo to.
try this instead:
$ sudo bash -c 'echo $PATH'
add a comment |Â
up vote
4
down vote
accepted
$PATH is expanded before sudo is run. Therefore you are seeing the value of PATH for you, and not for the user you sudo to.
try this instead:
$ sudo bash -c 'echo $PATH'
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
$PATH is expanded before sudo is run. Therefore you are seeing the value of PATH for you, and not for the user you sudo to.
try this instead:
$ sudo bash -c 'echo $PATH'
$PATH is expanded before sudo is run. Therefore you are seeing the value of PATH for you, and not for the user you sudo to.
try this instead:
$ sudo bash -c 'echo $PATH'
edited Jul 28 at 21:22
slmâ¦
232k65479649
232k65479649
answered Jul 28 at 10:49
ctrl-alt-delor
8,54031946
8,54031946
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459027%2fwhich-is-not-searching-full-path%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
And where is
abcactually located ?â steve
Jul 28 at 10:50
2
Note that
sudo echo $PATHwill not show root's $PATH. gets resolved by current she'll and then passed to sudo....â steve
Jul 28 at 10:52
1
Also note that if you use sudo to actually execute
abc, it is typically configured to search its ownsecure_pathrather than the root user'sPATH. Seeman sudoers.â steeldriver
Jul 28 at 11:25