root和用户使用sudo的不同路径变量 [英] Different path variables for root and user using sudo
问题描述
我正在Oracle Linux上运行,当我尝试使用 apachectl start
命令启动Apache服务器时,出现了一些错误.但是,当我尝试使用 sudo apachectl start
命令时,它运行良好.我检查了两个版本: apachectl -V
和 sudo apachectl -V
,我注意到这两个版本使用不同的版本(2.2.15和 sudo
,而不是2.4.4).
I am running on Oracle Linux, and when I tried to start my Apache server with the apachectl start
command, I received some errors. However, when I tried to use the sudo apachectl start
command, it runs fine. I checked the versions for both: apachectl -V
and sudo apachectl -V
, and I have noticed that the two use different versions (2.2.15 with sudo
, 2.4.4 without).
这是为什么?sudo在查找命令时是否使用其他路径?
Why is this? Does sudo use a different path when looking for commands?
感谢您的帮助.
推荐答案
在您的用户帐户中尝试以下命令:
Try the following command in your user account:
env | grep ^PATH=
现在,将其与以root身份运行的同一命令的输出进行比较:
Now, compare this to the output from the same command run as root:
sudo env | grep ^PATH=
路径是否相同?
这篇关于root和用户使用sudo的不同路径变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!