Linux sh: 0: getcwd() 失败:引用的驱动器上没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12758125/
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
sh: 0: getcwd() failed: No such file or directory on cited drive
提问by CrazyKitty Rotoshi
I am trying to compile ARM code in Ubuntu 12.
我正在尝试在 Ubuntu 12 中编译 ARM 代码。
Everything is working fine when I put the code in the local directory.
当我将代码放在本地目录中时,一切正常。
But when I put the code in cited mount directory error shows up:
但是当我将代码放在引用的挂载目录中时,就会出现错误:
making testXmlFiles
sh: 0: getcwd() failed: No such file or directory
ARM Compiling xxxxx.c
sh: 0: getcwd() failed: No such file or directory
Here is my setting in fstab
这是我在 fstab 中的设置
//10.0.0.1/data /mnt/data cifs auto,noserverino,credentials=/root/.smbcredentials,file_mode=0777,dir_mode=0777,uid=user,gid=users,noperm 0 0
What is going on here? What could cause this error?
这里发生了什么?什么可能导致此错误?
回答by Hooman
This error is usually caused by running a command from a directory that no longer exist.
此错误通常是由从不再存在的目录中运行命令引起的。
Try changing your directory and re-run the command.
尝试更改您的目录并重新运行该命令。
回答by Aritrik
Please check the directory path whether exists or not. This error comes up if the folder doesn't exists from where you are running the command. Probably you have executed a remove command from same path in command line.
请检查目录路径是否存在。如果您运行命令的位置不存在该文件夹,则会出现此错误。可能您已经从命令行中的同一路径执行了删除命令。
回答by timxor
Try the following command, it worked for me.
尝试以下命令,它对我有用。
cd; cd -
回答by Is Ma
In Ubuntu 16.04.3 LTS, the next command works for me:
在 Ubuntu 16.04.3 LTS 中,下一个命令对我有用:
exit
Then I've login again.
然后我又登录了。
回答by yunus
Even i was having the same problem with python virtualenv It got corrected by a simple restart
即使我在 python virtualenv 上也有同样的问题 它通过简单的重启得到纠正
sudo shutdown -r now
回答by smcjones
This can happen with symlinks sometimes. If you experience this issue and you know you are in an existing directory, but your symlink may have changed, you can use this command:
有时,符号链接可能会发生这种情况。如果您遇到此问题并且您知道您位于现有目录中,但您的符号链接可能已更改,您可以使用以下命令:
cd $(pwd)
回答by Roberto Rodriguez
That also happened to me on a recreated directory, the directory is the same but to make it work again just run:
这也发生在我重新创建的目录中,目录是相同的,但要使其再次运行,只需运行:
cd .
回答by Tech Nomad
In my case nothing above has worked. After banging my head against the wall for a while I've found out, that I've destroyed the /etc/passwd
entries by running a custom-made-linux-server-setup-bash-script which worked well previously, but this time the regex within the "sed" command erased all the existing entries :D
After copy pasting the default entries from another working linux server I could finally restart sshd.
在我的情况下,以上都没有奏效。在我的头撞墙一段时间后,我发现,我/etc/passwd
通过运行以前运行良好的自定义 linux-server-setup-bash-script破坏了条目,但这次是正则表达式“sed”命令删除了所有现有条目 :D 从另一个工作的 linux 服务器复制粘贴默认条目后,我终于可以重新启动 sshd。
So don't forget to backup the original /etc/passwd
file before applying any regex replacements on it :)
因此,/etc/passwd
在对其应用任何正则表达式替换之前,请不要忘记备份原始文件:)