-bash: ls: 命令未找到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43633128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:04:46  来源:igfitidea点击:

-bash: ls: command not found

bashmacos

提问by Kirti Parghi

I have setup react-native in my system. I have mac OS X El Capitan.

我在我的系统中设置了 react-native。我有 Mac OS X El Capitan。

After completing setup of react native, whenever i open my terminal and type command ls then, it shows "command not found".

完成 react native 的设置后,每当我打开终端并输入命令 ls 时,它都会显示“找不到命令”。

export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

After executing above two lines in my terminal, everything works fine. ls command is working after that. But once i close my terminal and again open it, ls command stops working and it shows "command not found".

在我的终端中执行以上两行后,一切正常。ls 命令在那之后工作。但是,一旦我关闭终端并再次打开它,ls 命令就会停止工作并显示“找不到命令”。

I have also tried to add above two lines in .bash_profile file, but didn't get success. I don't know how to get rid of this issue.

我也尝试在 .bash_profile 文件中添加以上两行,但没有成功。我不知道如何摆脱这个问题。

回答by Ebin Joy

Add following line to you .bash_profile

将以下行添加到您 .bash_profile

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b??in

Simply you can do it by following command

只需通过以下命令即可完成

echo "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b??in" >> ~/.bash_profile

After that please restart your terminal

之后,请重新启动您的终端