长话短说,
"command not found" 找不到命令
这类错误出现的原因有很多,根据具体情况分析,常见的有以下3种
1.不是可执行命令,也就是你输入的代码不合法,没有被定义
[root@localhost test]# jsjsjjdjd
bash: jsjsjjdjd: command not found...
[root@localhost test]# $? 像$?这种不可直接执行的命令会出现这类错误,修改我们的输出格式就好了
bash: 0: command not found...
#比如
[root@localhost test]# echo $? #echo为可执行命令
127
2.如果是echo、mv、vim等都出现command not found 报错的话,很大概率就是未配置环境变量
解决方法:
[root@localhost test] echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost test] vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
export PATH
3.如果命令别名被修改也会出现这类错误
[root@localhost test] ll
total 32
-rw-r--r--. 1 root root 197 Aug 22 22:38 test1.sh
-rw-r--r--. 1 root root 429 Aug 20 16:11 test2.sh
-rw-r--r--. 1 root root 233 Aug 20 16:03 test3.sh
[root@localhost test] unalias ll
[root@localhost test] ll
bash: ll: command not found...
[root@localhost test] alias #查看命令别名
[root@localhost test] alias ll='ls -l --color=auto' #定义ll的命令别名