*nix filesystem concept
To add jus a little to this an inode (Index Node) is a data structure used in Unix-like file systems (such as ext4, XFS, etc.) to store metadata about a file or directory. It contains information about the file’s attributes, such as its size, ownership, permissions, timestamps (creation, modification, access), and pointers to the data blocks on the disk where the actual content is stored. However, an inode does not contain the file's name or its data itself.
When a file is created, an inode is allocated to it, and the file name is stored separately in a directory entry that maps to that inode. Each file has a unique inode, and the file system uses the inode to retrieve the file's metadata and data blocks.
Key points:
- Inodes store metadata, not the actual data or file name.
- Inode number: A unique identifier for each inode in the file system.
- Inodes play a crucial role in **file management** and access, helping the system locate files and manage their properties.
Why do I need to know about this? Because When you create a hard link to a file using ln, a new directory entry is created, but the inode number remains the same. Both filenames now refer to the same inode, and when either of the links is deleted, the inode is not removed until the last link to it is deleted. This feature allows files to be referenced by multiple names in different directories without duplicating the file's content on disk. ¹
In summary, inodes are essential for managing files in a file system, storing all crucial details about the file except its name and content. The
stat command can be used to identify the inode number of a file, if needed.
¹This w-u is a little more complete than I'd originally left it thanks to remarks from C-Dawg, to whom gratitude.
$ xclip -o | wc -w
205