-bash: sudo: 没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37787062/
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: No such file or directory
提问by James Wong
Whenever opening the terminal, I always end up with this same error.
每当打开终端时,我总是以同样的错误告终。
-bash: export: `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/hadoop/bin': not a valid identifier
And whenever running command lines, the terminal throws an error, like
每当运行命令行时,终端都会抛出一个错误,比如
-bash: sudo: No such file or directory
I can't even edit ~/.bashrc through gedit ~/.bashrc
which I think could be the problem. But a echo $PATH
gives me a empty line though.
我什至无法编辑 ~/.bashrc gedit ~/.bashrc
,我认为这可能是问题所在。但是 aecho $PATH
给了我一个空行。
By the way, all those stuff happen under my personal account. There's a dedicated hadoop user account, which I created specifically for running hadoop and in fact works fine without a glitch.
顺便说一句,所有这些事情都发生在我的个人帐户下。有一个专用的 hadoop 用户帐户,我专门为运行 hadoop 创建了该帐户,实际上它可以正常工作而不会出现故障。
I really appreciate it if anyone could tell me what's going on here, and it's been frustrating me for a week or so. Thanks in advance.
如果有人能告诉我这里发生了什么,我真的很感激,这让我沮丧了一个星期左右。提前致谢。
EDIT:
编辑:
It turned out that before I created the second account(for hadoop), I modified its bashrc at the end of the file, which I totally forgot. Therefore it was bound to run into trouble. Hugh thanks again to you guys for helping me out, reminding me to check the bashrc file and obviously how to run command line in this situation.
原来,在我创建第二个帐户(用于hadoop)之前,我在文件末尾修改了它的bashrc,我完全忘记了。因此,它必然会遇到麻烦。Hugh 再次感谢你们帮助我,提醒我检查 bashrc 文件以及显然如何在这种情况下运行命令行。
采纳答案by Chris Lear
Run this:
运行这个:
/bin/bash --noprofile --norc
Then you should have a bash prompt that is tame enough for you to use without getting errors all the time.
然后,您应该有一个足够温和的 bash 提示,供您使用而不会一直出错。
Now use /bin/mv ~/.bashrc ~/.bashrc-old
to get rid of the .bashrc
file that is presumably causing the problems.
现在用于/bin/mv ~/.bashrc ~/.bashrc-old
摆脱.bashrc
可能导致问题的文件。
Then use /bin/cp /etc/skel/.bashrc ~/
to get yourself a new .bashrc
然后用/bin/cp /etc/skel/.bashrc ~/
给自己一个新的.bashrc
Alternatively, you can try this, which will probably work with your existing .bashrc, but is a bit of a punt:
或者,您可以尝试这个,它可能适用于您现有的 .bashrc,但有点笨拙:
/bin/sed -i.bak 's/export PATH /export PATH=/' ~/.bashrc
This replaces the line export PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/hadoop/bin
with the same thing except with an =
instead of a space, which looks like the root of the problem.
这将export PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/hadoop/bin
用相同的东西替换该行,除了用一个=
而不是一个空格,这看起来像是问题的根源。