Linux must allocate an index node (inode) for every file and directory in the filesystem. Inodes do not store actual data. Instead, they store the metadata where you can find the storage blocks of each file’s data.
In other words, a “file” is actually composed of three different things:
- a PATH in the filesystem
- an inode with metadata
- data blocks pointed to by the inode
Metadata in an Inode
The following metadata exists in an inode:
- File type
- Permissions
- Owner ID
- Group ID
- Size of file
- Time last accessed
- Time last modified
- Soft/Hard Links
- Access Control List (ACLs)
Check the Inode Number in a Specific File
The command stat
displays the file statistics, including the unique inode number:
stat
To see the metadata for a certain file, we can use the stat()
or fstat()
system calls. These calls take a pathname (or file descriptor) to a file and fill in a stat structure.