Sunday 25 November 2018

bash - Why I can access the dir // in Linux?


I found this dir in my ubuntu server


momo@myubuntuserver:/$ cd /
momo@myubuntuserver:/$ pwd
/
momo@myubuntuserver:/$ cd //
momo@myubuntuserver://$ pwd
//
momo@myubuntuserver://$ cd ///
momo@myubuntuserver:/$ pwd
/

why this dir exists ? How does it work ?



Answer



From Bash FAQ:


E10) Why does `cd //' leave $PWD as `//'?

POSIX.2, in its description of `cd', says that *three* or more leading
slashes may be replaced with a single slash when canonicalizing the
current working directory.

This is, I presume, for historical compatibility. Certain versions of
Unix, and early network file systems, used paths of the form
//hostname/path to access `path' on server `hostname'.

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...