-bash: sudo: 命令未找到 Mac OS X(EC2 CLI 问题?)

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

-bash: sudo: command not found Mac OS X (EC2 CLI prob?)

macosbashsudo

提问by Robert C Edwards

Getting the error:
-bash: sudo: command not found
echo $PATHoutputs PATH:EC2_HOME/bin
I'm running Mac OSX 10.8.3

得到错误:
-bash: sudo: command not found
echo $PATH输出PATH:EC2_HOME/bin
我正在运行 Mac OSX 10.8.3

That seems wrong even for a n00b like me. How do I fix my $PATH and return my computer to it's former self?

即使对于像我这样的 n00b,这似乎也是错误的。如何修复我的 $PATH 并将我的计算机恢复到以前的状态?

回答by Atropo

As stated in the comments the right files to set up your $PATHvariable are: ~/.profileor ~/.bash_profile

如评论中所述,设置$PATH变量的正确文件是:~/.profile~/.bash_profile

export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH

In this way when you re-enter in the console your PATHwill work fine. You can add other directories to your $PATHas you like.

这样,当您重新进入控制台时,您PATH将可以正常工作。您可以根据需要将其他目录添加到您的目录中$PATH

If you just copy and past that line in an active console you just set the PATHvariable temporary, when you logout and login again you will loose your path, so add it in your ~/.bashrcfile.

如果您只是在活动控制台中复制并通过该行,您只需设置PATH临时变量,当您注销并再次登录时,您将丢失您的路径,因此将其添加到您的~/.bashrc文件中。

回答by TheDarkKnight

I'm not sure how you've managed to get into that state, though this articleexplains how you can set your path.

我不确定你是如何进入这种状态的,尽管本文解释了如何设置你的路径。

If it helps, the output from my echo $PATH is: -

如果有帮助,我的 echo $PATH 的输出是:-

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

回答by Majid

  1. go to shell
  2. choose new command
  3. put this : sudo vim .bash_profile
  4. then put : export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH
  1. 去壳
  2. 选择新命令
  3. 把这个: sudo vim .bash_profile
  4. 然后放: export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH