Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my Linux box, in bash, I have access to a "double root" folder denoted by two forward slashes:

tomas:~ $ cd /
tomas:/ $ ls
bin/ cdrom@ ...
tomas:/ $ cd //
tomas:// $ ls 
bin/ cdrom@ ...

The content of the folder and its subfolder is identical to the "normal" single slash root. The double slash does not go away when I access its subfolders. The annomaly does not repeat itself with three or more slashes; these are simple synonyms for the root:

tomas:// $ cd home/tomas
tomas://home/tomas $ cd ///
tomas:/ $ cd ////
tomas:/ $

What kindof place is it? Is it a bug? Can anyone explain the annomaly?

share|improve this question
good question - i noticed the same behavior but never asked why this happens. – lajuette Sep 17 '10 at 14:50
up vote 18 down vote accepted

From Bash FAQ E10:

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
Thank you. Clear answer. – Tomas Sep 14 '10 at 14:45
Domain/OS is one such system. – grawity Sep 14 '10 at 15:46
The double slash thing is still used. It's part of the Universal (or Uniform; I can't seem to find a primary source) Naming Convention or UNC. It appears in Windows, Unix, and Linux. It happens to be the reason a double slash is used in URLs. – Isaac Rabinovitch Dec 3 '12 at 7:11

"It's not a bug, it's a feature!"

You're still in the same root directory. I don't know the origins of this, but suspect it may have something to do with building strings for absolute paths. If anyone else knows for sure, pipe up.

share|improve this answer

Multiple slashes are just ignored by the tools you have used and you are always getting to the same root folder.

share|improve this answer
So why does bash change /// into / while leaving // as is? – Tomas Sep 14 '10 at 12:07

Multiple slashes are treated as a single slash for pathname-resolution purposes.

What you're seeing in the shell prompt is an artifact of bash PS1 handling (see section "PROMPTING" in the bash manpage).

[root@linux /]# cd /    ; echo $PWD
[root@linux /]# cd //   ; echo $PWD
[root@linux //]# cd /// ; echo $PWD
[root@linux /]# cd //// ; echo $PWD

The result is only a matter of presentation; you're always in the same root directory. You can check this by looking at /proc/$$/root.

[edit] Well I never knew this: The meaning of "//" is left undefined by the standards, but "///" and more slashes are equivalent to "/".

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .