Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does double slash // in `cd //` mean in Linux? [duplicate]

I've entered a command cd // instead of cd / by mistake and instead of getting an error as I'd expect the shell (Bash) showed a prompt as if I'm in the // directory:-

<username>@<hostname>://$ <username>@<hostname>://$ pwd // 

Listing the content of the directory shows that it is the same as /.

So what exactly cd // do and what's the difference from cd /?

like image 645
vitaut Avatar asked Dec 19 '13 20:12

vitaut


People also ask

What is double slash Linux?

The double slashes // are for replacing all occurrences of space with _ , if you put one slash / , only first space is going to be replaced. The space is there because you are replacing space (with underscore)

What do double slashes mean?

Particularly as a double slash in written work usually means "new line here". Follow this answer to receive notifications.

What does slashes mean in Linux?

Slash is the path separator in Linux. We use it to separate the current directory (.) from the file name.


1 Answers

Actually it means nothing and is ignored.

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

Also the Unix standards states:

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.

like image 121
Rahul Tripathi Avatar answered Oct 19 '22 07:10

Rahul Tripathi