What Is an Inode? Understanding File System Metadata and Links
This article explains the concept of an inode, its role in storing file metadata, its size and structure on disk, how inode numbers are used, and the differences between hard links, soft links, and directory entries in Unix/Linux systems.
What Is an Inode
An inode (index node) is a data structure that stores a file's metadata such as size, owner, timestamps, permissions, link count, and the locations of its data blocks.
Contents of an Inode
File size in bytes
Owner User ID
Group ID
Read, write, execute permissions
Three timestamps: ctime (inode change), mtime (content change), atime (last access)
Link count (number of directory entries pointing to the inode)
Locations of the file's data blocks
You can view an inode's information with the stat example.txt command.
Inode Size
Inodes also consume disk space. During formatting, the disk is divided into a data area and an inode table. Each inode is typically 128 or 256 bytes, and the total number of inodes is set at format time (e.g., one inode per 1 KB or 2 KB).
On a 1 GB disk with 128‑byte inodes and one inode per 1 KB, the inode table would occupy about 128 MB (12.8% of the disk).
To see inode usage, use df -i. To check the inode size, run sudo dumpe2fs -h /dev/hda | grep "Inode size".
Inode Number
Each inode has a unique number used by the operating system to identify files. Unix/Linux systems use inode numbers internally rather than file names; the name is merely a human‑readable alias.
When a file is opened, the system resolves the name to an inode number, reads the inode, then accesses the data blocks.
Use ls -i to display a file's inode number.
Directory Files
In Unix/Linux, a directory is also a file containing a list of directory entries (dirents). Each entry stores a file name and its corresponding inode number.
The ls /etc command lists file names in the directory, while ls -i /etc shows both names and inode numbers. Detailed file information can be obtained with ls -l /etc, which reads the inode data.
Hard Links
Normally, each inode number maps to a single file name, but Unix/Linux allows multiple names to point to the same inode, creating a hard link.
Hard links share the same inode and data; modifying the file through any name affects all. Deleting one name decrements the link count; when it reaches zero, the inode and its blocks are reclaimed.
Create a hard link with ln source_file target_file.
Directories have a default link count of two ("." and "..") plus one for each subdirectory.
Soft (Symbolic) Links
A soft link (symbolic link) is a special file whose contents are the path to another file. Accessing the soft link redirects the system to the target file.
If the target is removed, the soft link becomes dangling and yields a "No such file or directory" error. Unlike hard links, soft links do not affect the target's link count.
Create a soft link with ln -s source_path target_path.
Special Uses of Inodes
Files with problematic names can be removed by deleting their inode directly.
Renaming or moving a file only changes its directory entry; the inode number remains unchanged.
Running processes identify open files by inode number, allowing updates to replace a file's inode without restarting the software.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
