-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
-bash: sudo: command not found Mac OS X (EC2 CLI prob?)
提问by Robert C Edwards
Getting the error:-bash: sudo: command not found
echo $PATH
outputs 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 $PATH
variable are: ~/.profile
or ~/.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 PATH
will work fine.
You can add other directories to your $PATH
as you like.
这样,当您重新进入控制台时,您PATH
将可以正常工作。您可以根据需要将其他目录添加到您的目录中$PATH
。
If you just copy and past that line in an active console you just set the PATH
variable temporary, when you logout and login again you will loose your path, so add it in your ~/.bashrc
file.
如果您只是在活动控制台中复制并通过该行,您只需设置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
- go to shell
- choose new command
- put this :
sudo vim .bash_profile
- then put :
export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH
- 去壳
- 选择新命令
- 把这个:
sudo vim .bash_profile
- 然后放:
export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH