2

On my ubuntu box I accidentally just did cd // and noticed that my current path changed to //. ls showed the contents of my root directory.

When I try cd /// (or any other number of slashes) I'm just taken directly to the root.

I'm sure this isn't something I need to worry about in any way during every day life but I was wondering if there was some interesting curiosity about why it behaves this way.

Mingye Wang
  • 1,181
  • 9
  • 23
Aidan Kane
  • 139
  • 4
  • 1
    Ah ha – thanks @Brian! I did try to search for it, but it's not the most searchable kind of question (granted, you didn't seem to have any problem finding it). – Aidan Kane Oct 28 '15 at 16:38
  • 1
    See http://unix.stackexchange.com/questions/12283/unix-difference-between-path-starting-with-and. – Mingye Wang Oct 29 '15 at 19:02
  • 1
    @dhag This is actually more like the one I linked. The asker is talking about how his shell normalizes paths starting with multiple slashes. – Mingye Wang Oct 29 '15 at 19:53
  • Also (somewhat) related: [Strange difference between pwd and /bin/pwd](http://unix.stackexchange.com/q/145479/80216). – G-Man Says 'Reinstate Monica' Oct 29 '15 at 20:41

1 Answers1

-1

cd / means change directory to root. The amount of slashes does not make a difference.

(source): http://www.linfo.org/cd.html

  • 1
    If you think a question is in the wrong place, just flag it for migration. – EEAA Oct 28 '15 at 16:32
  • (1) Your source doesn’t support your answer; it says what `cd /` means (which we ***all*** already know) but doesn’t say anything about `cd //` or multiple slashes.  (2) Something it *does* say is “When used without specifying any directory name, cd returns the user to the previous current directory.” — which, of course, is wrong — so it’s not a very trustworthy source. – G-Man Says 'Reinstate Monica' Oct 31 '15 at 04:35