sh: 0: getcwd() failed: No such file or directory on cited drive

I am trying to compile ARM code on Ubuntu 12.04 (Precise Pangolin).

Everything is working fine when I put the code in the local directory.

But when I put the code in the cited mount directory, an 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:

//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?

2

8 Answers

This error is usually caused by running a command from a directory that no longer exists.

Try changing your directory and rerun the command.

6

That also happened to me on a recreated directory. The directory is the same, but to make it work again, just run:

cd .

Try the following command. It worked for me.

cd; cd -
2

This can happen with symbolic links sometimes. If you experience this issue and you know you are in an existing directory, but your symbolic link may have changed, you can use this command:

cd $(pwd)

In Ubuntu 16.04.3 LTS (Xenial Xerus), the following command works for me:

exit

Then I've login again.

1

Please check whether the directory path exists or not. This error comes up if the folder doesn't exist from where you are running the command.

Probably you have executed a remove command from the same path on the command line.

2

If some directory/folder does not exist, but somehow you navigated to that directory, in that case you can see this error.

For example:

  • currently, you are in the "mno" directory (path = abc/def/ghi/jkl/mno
  • run "sudo su" and delete mno
  • go to the "ghi" directory and delete the "jkl" directory
  • now you are in the "ghi" directory (path abc/def/ghi)
  • run "exit"
  • after running the "exit", you will get that error
  • now you will be in "mno"(path = abc/def/ghi/jkl/mno) folder. That does not exist.

So, generally this error will show when the directory doesn't exist.

To fix this, simply run "cd;" or you can move to any other directory which exists.

In my case, none of the previous answers 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.

So don't forget to back up the original /etc/passwd file before applying any regular expression replacements on it :)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like