7

While in the / directory and use ls -a the result will contain . and ..

I can understand the existence of the . that is a pointer for the directory itself. What it is the meaning of having the .. in the / directory while there is no parent directory for the /?

8

Many softwares work on the assumptions, not in fact guaranteed to them by POSIX.1 but traditionally the case on UNIX systems and enshrined in much UNIX literature, that (to quote one such piece of UNIX literature):

Every directory contains the file names dot and dot-dot (. and ..) whose inode numbers are those of the directory and its parent directory, respectively. […] The program mkfs initializes a filesystem so that . and .. of the root directory have the root inode number of the file system.

— Maurice J. Bach (1986). The Design of the UNIX Operating System. Prentice Hall. p. 73

For example: The old getcwd() library function (on systems that provided no special kernel support for it) relies upon this to know when to stop tracing up the chain of .. entries when composing the current directory name. It stops when it reaches a directory that is its own parent, or cannot traverse to ...

So the reason that the root directory has (or as far as applications-mode programs are concerned at least appears to have as seen through the system API) a .. entry is that a lot of stuff is based upon the assumption that every directory has .., and that .. in the root being a loop can be used for detecting that one is at the root.

POSIX.1 does not in fact guarantee that the root directory has a .., merely specifying that programs have to account for the possibility of a loop if there is a .. in the root directory. This is to permit non-UNIX systems to be POSIX-conformant too. There are file systems where the absence of .. indicates that a directory is a root directory. And there are, as Bach himself discusses, systems where there is a directory above the root, which POSIX.1 allows for in its discussion of absolute pathnames that begin with two slashes (similar to the Universal Naming Convention used in Microsoft local area network systems).

Linux (and thus Ubuntu Linux), however, provides the stricter guarantees of the UNIX paradigm.

-1

Very simply: by means of file directory, ./ means this folder, while ../ means where the file is (e.g when I'm in the directory user/home/me/Desktop, then ../ will bring me to /user/home/me).

  • Ok. How does this answer the question, that / has no parent directory for /../ to point to? – muru Dec 26 '15 at 10:48
  • Now that your question is well edited, I understand what you actually asked ;)<br> About that, the answer of JdeBP explains well. – Tzahi Leh Dec 26 '15 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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