This question already has an answer here:

How is "/a/./b/../../c/" equal to /c?

I saw this as a question on one of the Stack Exchange sites. Apparently .. means to pop the stack(?). Why is this the case?

marked as duplicate by dhag, Scott, Archemar, Stephen Kitt, dr01 Dec 14 '15 at 9:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Assume root looks like:


Let's break it down to componenets:
/ -> root
/a -> in (a)
. -> THIS dir path
/a/./ -> still in /a
/a/./b -> in /a/b
.. -> go "up" one level
/a/./b/.. -> /a/b/.. -> /a
/a/./b/../.. -> /a/.. -> /
/a/./b/../../c -> /c


In the *nix world, every directory is a child directory of a parent directory. Every directory has an implicit '.' directory that refers to itself, and an implicit '..' directory that refers to its parent. So if you're in a particular directory, and you change directory (cd) to '.' (commands starting with '$' can be run on your command line!), you'll stay in the same directory:

$ pwd
$ cd .
$ pwd

But changing directory to '..' goes up one:

$ cd ..
$ pwd

And changing directory to '..' goes up again:

$ cd ..
$ pwd

The only directory that is an exception to this rule is the root directory, which doesn't have a parent directory:

$ cd ..
$ pwd
$ cd ..
$ pwd

Check out this tutorial on Unix directories for more details.


/ is your root directory. It has a directory structure like,

___ /c
___ /a
______/b (child dir of a)
___ /other dirs

Now , a single dot . means the same directory and double dots (..) Means the parent directory.

So in your example , when you use . in the path it stays in the same directory and when you use .. It jumps back to its parent directory. So eventually by jumping up, it reaches the root (/) so it's equivalent to /c

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