当我尝试运行命令时,出现错误“无法找到该命令,因为 '/usr/bin' 未包含在 PATH 环境变量中”

krs*_*krs 6 bash

当我尝试在终端中运行时,出现错误The command could not be located because '/usr/bin' is not included in the PATH environment variable

例如。

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

和喜欢

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

问题是什么以及解决方法是什么?

小智 4

看起来你的 $PATH 是空的。尝试一下echo $PATH,输出应该与此类似:

/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/root/bin
Run Code Online (Sandbox Code Playgroud)

如果没有,您应该检查您的.bash_profile.bashrc. 或者如果使用su username命令切换用户,su - username下次应该使用。