Is the slash (/) really part of the name of the Linux root directory? Or is it just a symbol for it?

What about /etc and so on?


Suppose /dev/sda2 is the block device of a Linux root directory.

$ sudo debugfs /dev/sda2
debugfs 1.44.1 (24-Mar-2018)
debugfs:  pwd
[pwd]   INODE:      2  PATH: /
[root]  INODE:      2  PATH: /
debugfs:  stat /
Inode: 2   Type: directory    Mode:  0755   Flags: 0x80000
Generation: 0    Version: 0x00000000:00000077
User:     0   Group:     0   Project:     0   Size: 4096
File ACL: 0
Links: 25   Blockcount: 8
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x5b13c9f1:3f017990 -- Sun Jun  3 15:28:57 2018
 atime: 0x5b13ca0f:3b3ee380 -- Sun Jun  3 15:29:27 2018
 mtime: 0x5b13c9f1:3f017990 -- Sun Jun  3 15:28:57 2018
crtime: 0x5aad1843:00000000 -- Sat Mar 17 16:59:39 2018
Size of extra inode fields: 32

So there is a directory in there, inode #2, but it hasn't a name.

  • Regarding your recent update showing some debugfs output. Can you clarify how this changes the question? – Kusalananda Jun 3 '18 at 12:58
  • It dosn't. I just wanted to complete the answers. but i didnt want to add another one. so i updated it. if u can put thease line in your answer in will delete them – mlibre Jun 3 '18 at 13:22

The POSIX.1-2008 standard says

A pathname consisting of a single / shall resolve to the root directory of the process. A null pathname shall not be successfully resolved.

The standard further makes a distinction between filenames and pathnames. / is the pathname for the path of the root directory. The name of the directory is "the root directory", but in the filesystem it is nameless, it does not have a filename. If it had a filename, that name would be a directory entry in the directory above the root directory, and there is no such directory.

For clarity: / is not the name of the root directory, but the path to it, its pathname.

/etc is another pathname. It is the name of the absolute path to the etc directory. The name of the directory at that path is etc (its filename is etc).

/usr/local/bin/curl is the pathname of the curl executable file in the same way that /etc is the pathname of the etc directory.


slash is a separator; directory names do not include separators, but full pathnames include the separators.

So the "root-level" / has no name. On most Unix-like systems, this is treated as a special case like . and .. (though of course there is no difference between the two at the root level).

Nomenclature can differ. POSIX.1-2017, for example, lists some commonly used definitions:

  • 3.2 Absolute pathname

    A pathname beginning with a single or more than two <slash> characters; see also Pathname.

  • 3.271 Pathname

    A string that is used to identify a file. In the context of POSIX.1-2008, a pathname may be limited to {PATH_MAX} bytes, including the terminating null byte. It has optional beginning <slash> characters, followed by zero or more filenames separated by <slash> characters. A pathname can optionally contain one or more trailing <slash> characters. Multiple successive <slash> characters are considered to be the same as one <slash>, except for the case of exactly two leading <slash> characters.

    Note: If a pathname consists of only bytes corresponding to characters from the portable filename character set (see Portable Filename Character Set), <slash> characters, and a single terminating <NUL> character, the pathname will be usable as a character string in all supported locales; otherwise, the pathname might only be a string (rather than a character string). Additionally, since the single-byte encoding of the <slash> character is required to be the same across all locales and to not occur within a multi-byte character, references to a <slash> character within a pathname are well-defined even when the pathname is not a character string. However, this property does not necessarily hold for the remaining characters within the portable filename character set.

  • 3.272 Pathname Component

    See Filename in Filename.

  • 3.170 Filename

    A sequence of bytes consisting of 1 to {NAME_MAX} bytes used to name a file. The bytes composing the name shall not contain the <NUL> or <slash> characters. In the context of a pathname, each filename shall be followed by a <slash> or a <NUL> character; elsewhere, a filename followed by a <NUL> character forms a string (but not necessarily a character string). The filenames dot and dot-dot have special meaning. A filename is sometimes referred to as a "pathname component". See also Pathname.

So... if you are looking for clarification, that might not be your first stop. Tutorials such as this UNIX Concepts page are helpful, e.g., pointing out that "full pathname" is synonymous with "absolute" pathname".

  • 3
    Nitpick: dot and dot-dot are filenames, not pathnames. Actually, the POSIX standard has the curious formulation "As a special case, in the root directory, dot-dot may refer to the root directory itself." (my emphasis). – Kusalananda Jul 24 '16 at 16:13
  • So, reading the specification to the letter, / is not a valid filename or a pathname component, and it's not a string that contains such components but it's still a completely valid pathname for one certain directory. Which has to exist, though the part that demands this doesn't mention its "name". Somehow, I find this slightly amusing. – ilkkachu Jul 24 '16 at 17:04
  • It's answered in POSIX: It has optional beginning characters, followed by zero or more filenames separated by characters. – Thomas Dickey Jul 24 '16 at 17:07
  • @Kusalananda review the spec rationale for your emphasis. the may in spec defines is a clear statement of surety with regards to implementation tests. where may is used, the spec assures any budding adherent of defined behavior. in other words, any implementation may rely on .. at / linking /. – mikeserv Aug 28 '18 at 22:21

In Unix, files (and directories are just files) don't have "names". Links have names, links are entries in a directory that map names to files.

You might say, that links give names to files, but note: this implies that a file can have more than one name, since it can have more than one link.

Since the root directory is, well, the root directory, there is no "higher-up" directory within which there could be a link to it, so there cannot be a name associated with it. It would theoretically be possible to add a link to the root directory within some other directory, but most Unices forbid adding links to existing directories, because it may lead to cycles in the filesystem hierarchy (which is actually a directed graph), and detecting cycles in a graph is expensive, but not detecting them can lead to infinite recursion when trying to resolve names within the kernel.

So, basically, the root directory has no name, because there is no directory above it within which we could record the name.

As was pointed out in other answers, we need to distinguish between a name and a path(name). The root directory can be referred to via the path(name) /.

  • Yes, files can have more than one name, just like people. My younger daughter's husband normally goes by his middle name, but he obviously has to answer to his first name too. The root directory's main name is "/", pronounced "slash", because its absolute pathname is "/" (and names based on relative pathnames aren't particularly helpful). (Calling it "root" risks confusion with "/root", which should always be called "slash root". – Monty Harder Jul 25 '16 at 16:16
  • 1
    I like the point that it has no name because there is no higher directory in which to record that name. That clarifies the concept nicely. – Joe Jul 30 '16 at 7:25

The use of the word "name" is a little bit flexible; it can refer to a "fully qualified path name"; it could refer to the "directory entry"; it could refer to the "file name" passed to various functions or routines.

So, for example, /etc/foo and /var/tmp/../../etc/foo and /tmp/../../../../../../foo are all ways of referring to the same file; they're all valid names, as is foo when in the /etc directory.

So let's go back to basics.

A filename in unix is made of of components separated by the directory separator /. Pretty much the only restriction on components is that they can't contain the / or NUL characters; anything else is permitted.

So the "fully qualified path name" of /etc is the full string: /etc. This means it has the etc component in the root directory.

Similarly /x/y/z/foo would have the foo component in the /x/y/z directory.

Now the root directory is unique in that it has no component in a parent directory; it only has the full pathname as its name: /.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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