Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I mistakenly typed cd // instead of cd /. To my surprise, current directory showed up as //.

What is that directory? Why does it exist?

apple@snipped $ pwd
/home/apple
apple@snipped $ cd /
apple@snipped $ pwd
/
apple@snipped $ cd //
apple@snipped $ pwd
//
apple@snipped $ cd ///
apple@snipped $ pwd
/
share|improve this question

2 Answers 2

up vote 14 down vote accepted

// is usually the same as /. /// must be the same as /.

ls would have shown you that cd // took you to the root directory, the same as cd / does.

$ cd /
$ ls
bin
boot
dev
...
$ cd //
$ ls
(same as above)

The technical way to confirm they are definitely the same directory is:

$ cd /
$ stat -c "%i" .
2
$ cd //
$ stat -c "%i" .
2

they will print the same inode number, meaning they are the same thing.

The gory details are documented in the POSIX Pathname Resolution specification:

A pathname consisting of a single slash shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. 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.

share|improve this answer
2  
Thanks! Just one issue(?), it seems that I need to add . for the current directory for stat to work: stat -c "%i" . –  Zabba Jan 29 '11 at 2:17
    
Yep, thanks. Fixed. –  Mikel Jan 29 '11 at 2:20

/ , // , /// ... and so on all will take you to the root / directory. The only difference is that // will change the current directory prompt to //. This "MIGHT" be a bug in the shell (bash) code.

share|improve this answer

Your Answer

 
discard

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.