“bash:找不到命令”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15736010/
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 05:02:35  来源:igfitidea点击:

"bash : command not found" error

rubymacosbashpath

提问by ibadukefan

I am trying to setup my machine for development and I keep getting the error, -bash: command not found. I am getting while running various commands. I am brand new to this, trying to get into development, and am not sure how to fix it. From what I have read it may have something to do with my PATH. Again, I'm new to this so I really have no clue.

我正在尝试设置我的机器进行开发,但我不断收到错误,-bash: command not found. 我在运行各种命令时遇到了问题。我对此很陌生,正在尝试进行开发,但不知道如何解决。从我读过的内容来看,它可能与我的路径有关。同样,我是新手,所以我真的不知道。

new-host:~ Home$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin

new-host:~ Home$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@ global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr /local/bin:/opt/X11/bin:/usr/local/git/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin

采纳答案by ibadukefan

I didn't have a bash profile. So I created one and voila, no more errors. Thanks again fellas for trying to help a noob!

我没有 bash 个人资料。所以我创建了一个,瞧,没有更多的错误。再次感谢小伙子们试图帮助菜鸟!

回答by Randy Howard

On OS X, by default, bash should be located as /bin/bash. So if /bin is not in your path then you need to put it there. It sounds like you must have been tweaking the base OS X install considerably. That, or you have installed some packages (macports, fink, brew, etc.???) that have 'adjusted' your path variable, perhaps in undesirable ways.

在 OS X 上,默认情况下,bash 应位于/bin/bash. 所以如果 /bin 不在你的路径中,那么你需要把它放在那里。听起来您一定对基本的 OS X 安装进行了相当大的调整。那,或者您安装了一些软件包(macports、fink、brew 等),它们可能以不受欢迎的方式“调整”了您的路径变量。

If you can execute /bin/bash, then you just need to make /bin an entry in your PATH environment variable again. Places to check:

如果您可以执行 /bin/bash,那么您只需要再次将 /bin 设为 PATH 环境变量中的一个条目。检查的地方:

/etc/profile
/etc/bashrc
~/.profile
~/.bashrc

回答by MattDMo

Your only problem is bad typing. You get the error -bash: XXX: command not foundwhen you type something on the command line that isn't a built-in shell function or external executable program in your path. You got -bash: dvm: command not foundwhen you tried to run rvmbecause you typed dvminstead.

你唯一的问题是打字不好。-bash: XXX: command not found当您在命令行上输入的不是内置 shell 函数或路径中的外部可执行程序时,您会收到错误消息。-bash: dvm: command not found当你试图运行时,你得到了,rvm因为你输入了dvm

Your $PATHis fine, as /binis right in there in the middle, so there's no problem with /bin/bashbeing found.

$PATH的很好,/bin就在中间,所以/bin/bash被发现没有问题。

In order to see what the contents of /etc/profileor ~/.bashrcare, you can't just type their names, like you were doing in the comments to Randy Howard's question, you have to use a command like cat /etc/profileto list its contents.

为了查看/etc/profile或的内容~/.bashrc,您不能像在对 Randy Howard 问题的评论中所做的那样只输入它们的名称,您必须使用命令 likecat /etc/profile列出其内容。