Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 ?

share|improve this question

migrated from stackoverflow.com May 7 '13 at 13:59

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 9 down vote accepted

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'.
share|improve this answer
    
Thanks for your answer . –  Robert Guo May 7 '13 at 10:23

// is just / on Linux. As is ///, and ///bin//////ls is an alternative name for /bin/ls.

Type /bin/pwd to find out the real present working directory.

share|improve this answer
    
The interesting question is why don't the shell prompt and pwd normalise // like they normalise ///? –  Daniel Fischer May 7 '13 at 10:14
    
@DanielFischer: because according to the POSIX standard, // at the start of a path may have a special meaning to the OS, and Bash seems to cater to this. Linux doesn't attach such meanings, though. (I think Cygwin and other "Unix-for-Windows" packages use this to denote UNC network paths, but the convention goes back to Apollo Domain/OS.) –  larsmans May 7 '13 at 10:17
    
Thanks, didn't know that. –  Daniel Fischer May 7 '13 at 10:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.