Linux File System Concepts Explained
In this article
- Background: Why Linux File Systems Differ
- The Directory Hierarchy: A Map of the System
- How Files Are Stored: Inodes and Data Blocks
- File Types and Permissions
- Choosing a File System: ext4, XFS, Btrfs, and Others
- Mounting and the /etc/fstab File
- Common Problems and How to Diagnose Them
- Frequently Asked Questions
Linux file system concepts are the rules and structures that determine how data is stored, named, organized, and accessed on a Linux system. Unlike the drive-letter approach of Windows, Linux uses a single hierarchical tree that starts at the root directory (/), where every file and device is a node.
Background: Why Linux File Systems Differ
Linux inherited its file system philosophy from Unix, which was designed in the 1970s for multi-user, multitasking systems. The core idea is that everything—files, directories, devices, even running processes—is represented as a file. This uniformity lets standard tools read from a keyboard, write to a screen, or communicate over a network using the same basic operations.
Another key difference is that Linux does not use drive letters like C: or D:. Instead, storage devices are mounted at directories within the single tree. For example, a USB drive might appear at /media/usb, and a separate hard disk at /mnt/data. This makes the layout consistent across all systems, regardless of how many physical drives are attached.
The Directory Hierarchy: A Map of the System
The Filesystem Hierarchy Standard (FHS) defines the purpose of the main directories. While not every distribution follows it perfectly, most do. Knowing these paths helps you find configuration files, logs, and user data quickly.
/– The root of the entire file system. Only the superuser typically writes here./home– Contains a subdirectory for each user (e.g.,/home/alice) with their personal files and settings./etc– System-wide configuration files. For example,/etc/fstablists file systems to mount at boot./var– Variable data that changes frequently, such as logs (/var/log) and print queues./binand/sbin– Essential user and system binaries (commands) needed before/usris mounted./usr– Secondary hierarchy for installed software, including most executables and libraries./tmp– Temporary files; often cleared on reboot./dev– Device files that represent hardware (e.g.,/dev/sdafor the first SATA disk)./procand/sys– Virtual file systems that expose kernel and hardware information as files.
How Files Are Stored: Inodes and Data Blocks
Most Linux file systems (ext4, XFS, Btrfs) use inodes to store metadata about each file. An inode holds the file’s size, permissions, timestamps, owner, and pointers to the data blocks on disk. The file name is stored separately in a directory entry, which links the name to an inode number.
This separation explains several behaviors:
- Renaming a file does not change its inode number; only the directory entry changes.
- Hard links are multiple directory entries pointing to the same inode. Deleting one link does not remove the file until all links are gone.
- If the inode table is full, you cannot create new files even if free disk space remains.
When you run ls -li, the first column shows the inode number. The command df -i shows inode usage, which is a common troubleshooting step when you get “No space left on device” despite having free blocks.
File Types and Permissions
Linux treats everything as a file, but distinguishes types. The first character of ls -l output indicates the type:
-– Regular filed– Directoryl– Symbolic link (a pointer to another file)borc– Block or character devicep– Named pipe (inter-process communication)s– Socket (network communication)
Permissions are displayed as a 10-character string like -rwxr-xr--. The first character is the type, then three groups of three: owner, group, and others. Each group has read (r), write (w), and execute (x) bits. The numeric representation (e.g., 755) is a shorthand where read=4, write=2, execute=1, and the sum is the permission value.
A common misconception is that the execute bit on a directory means you can run it. In reality, it grants permission to traverse the directory—that is, to access files inside it. Without execute on a directory, you cannot cd into it or access any file within, even if file permissions allow it.
Choosing a File System: ext4, XFS, Btrfs, and Others
Linux supports many file systems, each with trade-offs. The most common choices for local disks are:
- ext4 – The default for most distributions. Mature, stable, supports files up to 16 TB and volumes up to 1 EB. Good general-purpose choice.
- XFS – Excels at large files and high throughput; often used for media servers and database workloads. Cannot be shrunk easily.
- Btrfs – Offers snapshots, compression, and checksumming. More features but historically less battle-tested than ext4.
- ZFS – Available via third-party modules (OpenZFS). Provides advanced data integrity and volume management, but licensing and kernel compatibility can be hurdles.
- F2FS – Designed for flash storage (SSDs, SD cards) to reduce write amplification.
For most desktop users, ext4 is the safest default. If you need snapshots or data checksums, consider Btrfs. For a high-performance server with many large files, XFS is a strong candidate. You can check your current file system with df -T.
Mounting and the /etc/fstab File
Mounting is the process of attaching a file system to a directory. The mount command does this temporarily; the /etc/fstab file defines permanent mounts that happen at boot. A typical line in fstab looks like:
UUID=abc123 /home ext4 defaults 0 2
The fields are: device (often by UUID to avoid name changes), mount point, file system type, options, dump flag, and fsck order. The fsck order is important: the root file system should have a 1, other local file systems a 2, and swap or network mounts a 0.
To see currently mounted file systems, run mount or findmnt. The umount command detaches a file system. A common error is “target is busy” when trying to unmount a disk that has open files; use lsof or fuser to find the process.
Common Problems and How to Diagnose Them
File system issues often manifest as cryptic errors. Here are frequent scenarios and their typical fixes:
- “No space left on device” – Check both disk blocks (
df -h) and inodes (df -i). If inodes are full, delete old small files (like cache) even if there is free space. - “Read-only file system” – Often caused by unclean shutdown or disk errors. Boot into recovery mode and run
fsckon the partition. - Corrupted files after a crash – Journaling file systems (ext4, XFS) replay their journal on mount to recover. If corruption persists, run
fsckmanually. - Slow performance – Check for full file systems, high I/O wait, or a fragmented disk. For SSDs, ensure the file system is mounted with the
discardorfstrimservice enabled.
Always back up important data before running fsck on a damaged file system. In most cases, you should unmount the partition first.
Frequently Asked Questions
What is the difference between a hard link and a symbolic link?
A hard link is another directory entry pointing to the same inode; it shares the same data blocks and cannot span different file systems. A symbolic link (symlink) is a special file that contains the path to another file; it can point to anything, including directories or files on other file systems, and breaks if the target is moved or deleted.
Why does Linux use a single root directory instead of drive letters?
This design simplifies management and makes the system more flexible. You can mount any storage device at any directory, and the rest of the system does not need to know about the underlying hardware. It also makes permissions and paths consistent across different machines.
How do I find out which file system a directory is on?
Use the df -T /path/to/directory command. It shows the file system type and mount point for the device containing that directory. For more detail, stat -f /path also displays the file system type.
What does “mount” mean in Linux?
Mounting attaches a file system (from a disk, partition, or network share) to a directory in the existing tree. After mounting, you access the contents through that directory. Unmounting detaches it, making the data inaccessible until mounted again.
Is it safe to delete files in /tmp?
Generally yes, but only if no running program needs them. The system clears /tmp on reboot by default, and many distributions use tmpfs which stores data in RAM. Deleting files there can break a running installer or update, so check what is using the files first with lsof.
What is the purpose of the /proc directory?
/proc is a virtual file system that provides a real-time view of kernel and process information. Files like /proc/cpuinfo and /proc/meminfo are not real files on disk; they are generated on the fly when read. Many system tools (like top and ps) read from this directory.