Linux – Is the slash (/) part of the name of the Linux root directory

fhsfilenamesfilesystemslinux

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?

Update

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
EXTENTS:
(0):9249

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

Best Answer

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.

The character / can never be part of a filename as it is the path separator.

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.

Related Question