Why cd .., typed at root folder, does not warn or fails with an error?

I would expect:

/$ cd ..
-bash: cd: ..: No such file or directory

Instead, I'm left at /. Of course, this is since .. does exist in /, and is simply /, just like .. I just wonder why it is like that.


6 Answers 6


According to the Open Group (responsible for the POSIX standard):

Each directory has exactly one parent directory which is represented by the name dot-dot in the first directory. [...] What the filename dot-dot refers to relative to the root directory is implementation-defined. In Version 7 it refers to the root directory itself; this is the behavior mentioned in POSIX.1-2008. In some networked systems the construction /../hostname/ is used to refer to the root directory of another host, and POSIX.1 permits this behavior.

A.4.13 Pathname Resolution

The dot-dot entry in the root directory is interpreted to mean the root directory itself. Thus, dot-dot cannot be used to access files outside the subtree rooted at the root directory.

chroot - change root directory


You don't get an error because even the / directory actually has a valid directory entry for .., but unlike with other directories it points to the directory itself and thus behaves identical to .:

$ ls -lid / /. /..
128 drwxr-xr-x 22 root root 4096 Apr 15 11:26 /
128 drwxr-xr-x 22 root root 4096 Apr 15 11:26 /.
128 drwxr-xr-x 22 root root 4096 Apr 15 11:26 /..

As the first column tells you, ., .., and / all have the same inode-number and thus are the same filesystem entries.

So even if you cd .. inside of / you just stay in /.

  • 13
    The question asks why the .. directory entry is there. Commented Apr 22, 2014 at 15:52
  • 3
    The only reason that comes to my mind, is that you want to treat / just like any other folder, including a valid entry for ... Otherwise you would have to treat / differently compared to all other folders in the system.
    – Dohn Joe
    Commented Apr 24, 2014 at 10:48

It's there because removing it would require creating special-case handling code in the kernel and the C libraries. Right now you can assume that there will always be a . and .. in any directory you go to.

The only special-case code required right now is in filesystem mounting code, where the code overrides the inode value of .. to point to the directory containing the mount point, since root directories aren't always root directories.

  • After all, it is impossible for 'parent-referral' in tree structures to be free of any special-case handling, isn't it? The root has to be special by definition, and any attempt to mask that will lead to special cases or confusion elsewhere.
    – musiphil
    Commented Apr 24, 2014 at 4:35
  • @musiphil In unix the special cases here are shuffled off to the mount command and its associated special file /etc/fstab. Commented Apr 24, 2014 at 6:12

Another reason '..' is in / is that if it wasn't there it would create another special case: root directory would have one hard link fewer than all the other directories (all directory nodes have n+2 links, where n is the number of direct subdirectories inside). This would break various programs that rely on in for optimization of directory scans.


Another way to check what . and .. in / really is:

$ readlink -f ..

$ readlink -f /.

$ readlink -f /..

As you can see, . and .. is pointed to /.


It's nice that it's there, because otherwise I wouldn't be able to spam ../../../../ to get to the root from a folder. If it didn't allow the .. at the root then I'd be stuck counting the number of folders down the working dir is.

  • 12
    What's wrong with cd /?
    – Bach
    Commented Apr 23, 2014 at 7:02
  • @Bach Sometimes, keyboard mashing is more fun. Besides, in many circumstances you're not trying to go to the root, in which case using ../ is better. I also do a lot of file operations in PHP, where I can't do / for several reasons. Commented Apr 23, 2014 at 7:18
  • 3
    The flip side is that maybe you accidentally enter too many ../s and operate on (or remove) a file you didn't intend to without error.
    – jamesdlin
    Commented Apr 24, 2014 at 0:58
  • 7
    Repeating ../ more times than needed and wishing it to work as intended looks like a (dormant) logic error to me, even if the filesystem apparently allows it.
    – musiphil
    Commented Apr 24, 2014 at 4:40
  • 2
    If root didn't have .., you could just do while [ -d .. ]; do cd ..; done
    – celtschk
    Commented Apr 25, 2014 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .