一分钟带你解决“command not found“报错

长话短说,

"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的命令别名

 

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值