Understanding Linux Filesystems: Inodes, Directory Structure, and Links Explained
This article introduces Linux's file system concepts, covering the unified view of resources as files, the hierarchical directory layout, the role of inodes in mapping logical to physical storage, and the differences between hard and soft links.
1 Introduction
We briefly look at Linux system disks, directories, and files.
2 Linux Filesystem
In Linux, all resources managed by the operating system—network interfaces, disks, printers, I/O devices, regular files, or directories—are treated as files.
This reflects the Unix philosophy that “everything is a file,” including hardware devices, which are represented as device files.
Linux supports five file types, as shown below:
3 Linux Directory Structure
The Linux filesystem hierarchy resembles an inverted tree, with the root directory at the top.
Common directory explanations:
4 What is an inode
An inode is a crucial concept for understanding Unix/Linux filesystems and disk storage.
Understanding inodes starts with file storage.
Files are stored on disks in sectors (512 bytes each).
The OS reads multiple sectors at once as a block, typically 4 KB (8 sectors).
The metadata about a file—owner, timestamps, size, etc.—is stored in an inode (index node).
Each file has a corresponding inode containing its information.
Linux uses the inode table to map a file’s logical structure to its physical blocks.
Each inode is a 64‑byte record containing size, owner, permissions, type, and a disk address table with 13 block numbers that point to the file’s data blocks.
When a file is accessed, the filesystem looks up the filename in the current directory, obtains the inode number, and uses the inode’s address table to assemble the file’s logical structure from its scattered blocks.
5 Hard Links and Soft Links
Hard link: a pointer to the same inode; creating a hard link increments the link count.
Limitations: cannot link across different filesystems; only superuser can create hard links to directories.
Soft (symbolic) link: a separate inode that stores the path to the target file, allowing cross‑filesystem links and greater flexibility.
Limitations: if the target moves, the link breaks; it consumes extra inode space for the path.
In practice, soft links are used more often. Key differences:
Hard links cannot cross partitions; soft links can.
Hard links point to the same inode; soft links create a new inode.
Deleting a hard link does not delete the original file; deleting a soft link does not affect the target file.
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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
