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?
abc
actually located ?sudo echo $PATH
will not show root's $PATH. gets resolved by current she'll and then passed to sudo....abc
, it is typically configured to search its ownsecure_path
rather than the root user'sPATH
. Seeman sudoers
.