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?

  • good question - i noticed the same behavior but never asked why this happens. – lajuette Sep 17 '10 at 14:50

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'.

  • 1
    Domain/OS is one such system. – user1686 Sep 14 '10 at 15:46
  • 1
    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.


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

  • 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: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11 The meaning of "//" is left undefined by the standards, but "///" and more slashes are equivalent to "/".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.