Shell – What does the ‘.’ dot mean as a working directory

directorypwdshellzsh

I'm not referring to the . you see in shell commands or in the output of ls -a.

I just ran an install script for a vpn application, and after the command exited, my terminal prompt was in the . directory.

This is my pwd output:

➜ pwd
.

I've never seen anything like this. Anyone know what this is?

Best Answer

That can happen when the current working directory has been deleted:

$ zsh -c 'mkdir dir; cd dir; rmdir $PWD; cd .; pwd; readlink /proc/self/cwd; command pwd'
.
/home/chazelas/dir (deleted)
pwd: couldn't find directory entry in ‘..’ with matching i-node

(the cd . causes zsh to double-check what its current directory is, and it reverts to . (the only possible valid path to the current working directory) when getcwd() returns with an error)

Related Question