添加环境变量引起的终端命令失效
$sudo
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.
自己添加了一个环境变量到~/.profile下之后,发现命令不可以用了,就是上面发生的情况。
当时添加环境路径操作:
sudo vi ~/.profile
#然后添加命令行到~/.profile
export PATH=/ work/software/:$PATH #问题出在这一行,work前面竟然有空格
source ~/.profile
此时vi sudo ......等一系列命令已经失效了,我都方了。。。。。。
解决办法
使用nano编辑~/.profile;nano是一个linux自带的终端文本编辑器
/usr/bin/nano ~/.profile
export PATH=/work/software/:$PATH #去掉work前面空格
source ~/.profile
检查一下,终端命令是否恢复工作
$ sudo
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
[command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
prompt] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
prompt] [-u user] file ...