Directory entries – mapping inodes to filenames
A directory acts as a catalog or a container for user files. The operations that are applicable to a directory are different than regular files. There are different commands for working with directories. A file is always going to be inside a directory, and to access that file, you need to specify the absolute or relative path in terms of directories. But like most things in Linux, directories are also treated as files. So, how does this all work?
Native Linux filesystems treat directories as files and store them like files. Like all regular files, a directory is also assigned an inode. There is one difference between the inode of a directory and a file. In the case of a directory, the type field in an inode is a directory. Remember, from our discussion about inodes, that an inode contains a lot of metadata about a file, but it doesn’t contain the name of the file. The filename is present in a directory. A directory can...