File Systems
File Systems
A file system is the OS subsystem that manages persistent data, storing users' files on disk hardware. Disk data can remain after the computer loses power, allowing persistent file storage. Its basic data unit is the file, and its purpose is to organize and manage files on disk.
Linux is often described by “everything is a file”: ordinary files and directories, as well as block devices, pipes and sockets, can be accessed through file interfaces.
Files and directories are managed hierarchically, as a tree. A folder contains subfolders or files, forming a tree structure. There are also special cases: team members working in different directories can share the same file.
Linux file systems use inodes and directory entries. An inode records metadata such as its number, file size, access permissions, timestamps and data locations on disk. A directory entry records the name, inode reference and relationships with other entries. Entries form the directory structure; directory records on disk are persistent, while the kernel maintains an in-memory directory-entry cache.
An inode uniquely identifies a file within its file system, while a directory entry records the filename. Their relationship is many-to-one: a file can have multiple names. For example, hard links are multiple directory entries referring to the same inode.
Hard Links and Symbolic Links
Links provide a way to share files, and mainstream file systems support them. They can be understood by comparison with Windows shortcuts. Linux commonly uses links to handle library versions or make deeply nested files easier to access.
Links are divided into hard links and symbolic links. In ordinary use, both generally allow the same reading and writing as regular files; an executable target can also be executed.
A hard link refers to the same inode as the original file, while a symbolic link stores a path to its target. Renaming or moving the original within the same file system does not change its inode, so a hard link still works. A symbolic link cannot access its target if its stored path no longer resolves.
Rename a file without losing its hard link
Unlock the complete interactive lab, deeper explanations, and curated reference answers.
KNOWLEDGE QUIZ
KNOWLEDGE QUIZ
Three names, two inodes, one shared report
In one directory and file system, file1 and hard link file2 share inode 37259183 and content REPORT. Symbolic link file3 has inode 13549669 and stores file1. There are no open handles.
- Rename file1 to report. Which names still read REPORT? Explain using the graph.
- Write EDITED through file2, remove report, then remove file2. After each step state the shared data, usable names and hard-link count.