3

I'm still a Linux newbie and I'm wondering: What is the Linux directory // ?

I can change dir (cd) to the root dir using cd /

~> cd /
/>

Using pwd (print name of working directory) tells me I'm in root (/)

/> pwd
/

Using ls (list directory contents) I see the following (using Raspbian Jessie)

/> ls
bin  boot  dev  etc  home  include  lib  lost+found  media  mnt  opt  proc  root  run  sbin  share  srv  sys  tmp  usr  var

By mistake I changed dir to // and found that it was valid:

~> cd //
//>

Also using pwd tells me I'm in a directory called // :

//> pwd
//

But using ls I see the that I'm probably still in 'something' looking like root.

//> ls
bin  boot  dev  etc  home  include  lib  lost+found  media  mnt  opt  proc  root  run  sbin  share  srv  sys  tmp  usr  var

... but telling me it's called // (rootroot ;-)

So what is directory // ?

Phiplex
  • 139
  • 1
  • 13
  • 2
    It's the same as `/`, but I too wonder why `cd //` sets the current directory to `//` – yoones Jul 26 '16 at 08:55
  • 1
    Apparently, every two `/` are stripped: `cd ///` goes to `/` and `cd ////` to `//`. – fedorqui Jul 26 '16 at 08:57
  • 1
    Perfectly covered in [unix, difference between path starting with '/' and '//'](http://unix.stackexchange.com/q/12283/40596), which was migrated from [so]. – fedorqui Jul 26 '16 at 09:02
  • Please forgive me for asking this kind of question here. I'm a newbie not only using Linux but also in understanding how to use the different Stack Exchange communities. I try to learn - but slowly! – Phiplex Jul 26 '16 at 19:26

1 Answers1

7

In Linux (and most other platforms), multiple slashes in a path are interpreted the same as a single slash. However, the POSIX specification states that:

A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.

// may be reserved for a special purpose (e.g: accessing a network drive in Cygwin). However, if you check ls in / and // on Linux you should see the same content.

fedorqui
  • 275,237
  • 103
  • 548
  • 598