Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I was working in my terminal, when I misspelled while cd to root (/). Accidentally, I typed // and I got in terminal:


When i type pwd, i get response // but when I type ls -s i got same list as in / directory.

When you type more than 2, i.e. /// you get:


Always 1 / except for 2. Is there any difference and what is // for?

share|improve this question

2 Answers 2

/ is equivalent to //

From the POSIX specification (emphasis added):

3.267 Pathname

A string that is used to identify a file. In the context of POSIX.1-2008, a pathname may be limited to {PATH_MAX} bytes, including the terminating null byte. It has optional beginning <slash> characters, followed by zero or more filenames separated by <slash> characters. A pathname can optionally contain one or more trailing <slash> characters. Multiple successive <slash> characters are considered to be the same as one <slash>, except for the case of exactly two leading <slash> characters.


4.12 Pathname Resolution

A pathname consisting of a single <slash> shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. If a pathname begins with two successive <slash> characters, the first component following the leading <slash> characters may be interpreted in an implementation-defined manner, although more than two leading <slash> characters shall be treated as a single <slash> character.

For a nice discussion of exceptions (cygwin and directories) see: How does linux handle multiple consecutive path separators (/home////username///file)?

share|improve this answer
thanks bro i will have look later sure! thanks –  Dimitris Theodoridis Mar 28 '13 at 17:02

You can add multiple slashes to a directory and it will not change anything.

E.g. these three commands all do the same:
cd /home
cd /home/
cd /home//

After any of these my current working directory is is set to /home (check with pwd).

I guess that you have your prompt configured to do something smart and that you ran into unanticipated behaviour. What do you get when you echo $PS1 ?

Link to a comment on which may explain it.

share|improve this answer
My PS1 in bash on OSX is "\h:\W \u\$" and I get this strange behavior, too. / and /// and //// and ///// all show up as /, but the special case of two forward slashes shows up as two forward slashes. –  Sparr Mar 28 '13 at 16:55
I got the \u@\h:\w (<b>u</b>ser at <b>h</b>ost, <b>w</b>orking dir) in Ubuntu 12.10 but I fail to reproduce the problem. –  Hennes Mar 28 '13 at 16:58
no i get always // when checking pwd in any case. for echo $PS1 i get: [\e]0;\u@\h: \w\a]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ –  Dimitris Theodoridis Mar 28 '13 at 16:59
I just manually set my PS1 and I can not reproduce it with two slashes. Weird. Not with 1, 3 or 4. Only with 2. I am at a loss to explain this. –  Hennes Mar 28 '13 at 17:07
Maybe this comment from unix.stackexchange is the answer: I believe that Windows POSIX compat APIs will also treat //remote/... the same as the UNC path \\remote\... format. – Stephen P Jan 20 '11 at 0:39 –  Hennes Mar 28 '13 at 17:09

Your Answer


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

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