这是没有sudo的PATH变量:
原文链接:https://www.f2er.com/ubuntu/354258.html$ echo 'echo $PATH' | sh /opt/local/ruby/bin:/usr/bin:/bin
这是带有sudo的PATH变量:
$ echo 'echo $PATH' | sudo sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
据我所知,sudo应该让PATH保持原样。这是怎么回事?如何更改这个? (这是在Ubuntu 8.04)。
更新:就我所见,没有一个脚本作为根以任何方式改变PATH。
从man sudo:
To prevent command spoofing,sudo
checks “.” and “” (both denoting
current directory) last when searching
for a command in the user’s PATH (if
one or both are in the PATH). Note,
however,that the actual PATH
environment variable is not modified
and is passed unchanged to the program
that sudo executes.