Why does '/' have an '..' entry?

/.. points to /:

$ ls -id /
2 /
$ ls -id /..
2 /..

Both have the same inode number, which happens to be 2 on this system. (The exact value doesn't matter.)

It's done for consistency. This way, there doesn't have to be code in the kernel to check where it currently is when it processes a .. in a path. You can say cd .. forever, and never go deeper than the root.


It's there because it's a guarantee made by Unix: every directory contains two entries, . which refers to itself, and .. which refers to the parent.

The root directory of the current namespace is special, in that .. points to the same thing as ., but not so special to break the guarantee made by the OS to programs. When those contracts are broken, things go wrong and everyone points fingers.

The root directory that you see might, in the filesystem on disk, actually have a different parent directory. The view of the filesystems provided in the mounted namespace is what enforces the .. = . rule for /. So if you're in a chroot() jail, you will see /.. = / even though someone outside the jail looking at /path/to/jail/.. will see /path/to instead.