sudo users can not find the environment variables sudo can not find the executable file usr local / at / / bin,

For security reasons, the use sudo to execute the command will be executed in a minimal environment, environment variables are reset to the default state.

So PATH This variable does not include the contents of user-defined settings, such as can not find / usr / local / bin / The following command
.bashrc in the user's home directory sudo adding the following to solve

$ vim ~/.bashrc #在最下面添加如下一行
alias sudo="sudo env PATH=$PATH"

 

source ~/.bashrc

之后sudo就有可以找到/usr/local/bin下面的命令了

Guess you like

Origin www.cnblogs.com/faberbeta/p/linux-shell032.html