How to resolve “sh: 0: getcwd() failed: No such file or directory”

Today I was working with git and for that I had created a “workspace” directory which contained some source files. During this activity I opened another terminal and deleted the workspace directory from second terminal, where as the first terminal, I forgot that, I was still inside that deleted “workspace” directory.

When I tried to install git from that deleted directory, I got an error like,

$ sudo apt-get install git

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

Solution :

This error was occurred because as I mentioned above, I had deleted the current working directory from where I tried to install git from second tab without realised I was working in that deleted directory.

hence the solution to the error “sh: 0: getcwd() failed: No such file or directory” is to come outside that directory or change to some other known directory and tried your command.

 cd .. 
Follow Lynxbee

Leave a Reply / Ask Question