错误信息:
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
错误原因:
修改配置文件的PATH 没有添加 :$PATH (:分号必须要),或者格式错误
解决办法:
1.首先导入临时变量(重启虚拟机之后失效),使得所有命令行暂时可以用
直接在命令行执行以下命令:
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
2.挨个检查环境变量文件
/root/.bash_profile
/etc/profile
修改后,执行 source /root/.bash_profile ,此时所有的命令恢复正常了