无法定位该命令,因为 PATH 环境变量中未包含“/usr/bin”

use*_*214 38 sudo

有人可以告诉我为什么我在尝试添加存储库时会收到此错误,以及我可以做些什么?

当我尝试使用以下方法添加存储库时:

sudo add-apt-repository ppa:upubuntu-com/tor
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Command 'sudo' is available in '/usr/bin/sudo'
The command could not be located because '/usr/bin' is not included in the PATH      
environment variable.
sudo: command not found
Run Code Online (Sandbox Code Playgroud)

jkt*_*123 48

你的 PATH 变量已经搞砸了。除非您尝试使用 运行受限用户,否则您rbash应该将 /usr/bin 放在$PATH. 对于终端会话,您可以通过运行来解决此问题:

export PATH="/usr/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)

正如@SylvainPineau 所提到的,这个答案涵盖了如何通过编辑/etc/environment文件来永久修复您的路径。

  • 或导出 PATH="/usr/sbin:$PATH" (3认同)