找不到 Bash 命令 — $PATH 损坏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18563847/
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 commands not found — $PATH damaged
提问by rrrub
I accidentally made a mistake when I changed my ~/.bash_profile
file and now I'm unable to run any command, such as ls
, touch
, sudo
, etc.
我不小心犯了一个错误,当我改变了我的~/.bash_profile
文件,现在我无法运行任何命令,如ls
,touch
,sudo
,等
When I write echo $PATH
I have this result:
当我写echo $PATH
我有这个结果:
$ echo $PATH
/usr/local/bin:
$
And when I type /bin/cat ~/.bash_profile
, I have this result:
当我输入时/bin/cat ~/.bash_profile
,我得到了这个结果:
export PATH=$HOME/local/node/bin:/usr/local/bin:$PATH
export PATH=/usr/local/bin:$PATHh
But I am unable to change it. Can someone help me, please?
但我无法改变它。有人能帮助我吗?
回答by Carl Norum
If you can do /bin/cat
, you should be able to /usr/bin/vi
, too. Alternately, just fix it in your local shell:
如果你能做到/bin/cat
,你也应该能做到/usr/bin/vi
。或者,只需在本地 shell 中修复它:
PATH=/bin:/usr/bin:/sbin:/usr/sbin
And then running your favourite editor should work again.
然后运行你最喜欢的编辑器应该会再次工作。