Linux File System

What Is the Linux File System?

The Linux File System is the foundation of Linux operating systems, used to store, organize, and access data on storage devices such as hard disks, SSDs, or USB drives.

Unlike Windows (which uses drive letters like C:\, D:\), Linux uses a single-root hierarchy starting from / (root directory).
Every file and directory is part of this single tree — even other partitions, USB drives, and CD-ROMs are mounted into it.

Linux File System Hierarchy (Structure)?

At the top of the structure is the root directory /, which contains all other directories.

Below is the standard structure and what each folder is used for:

  • /
  • bin/ → Essential user commands (ls, cp, mv, cat, mkdir)
  • boot/ → Files needed to boot the system (kernel, GRUB)
  • dev/ → Device files (hard disks, USBs, printers, etc.)
  • etc/ → System configuration files (/etc/passwd, /etc/hosts)
  • home/ → User home directories (/home/user1, /home/user2)
  • lib/ → Shared libraries for system programs in /bin and /sbin
  • media/ → Mount point for removable media (USB, CD)
  • mnt/ → Temporary mount point for filesystems
  • opt/ → Optional software packages (3rd party applications)
  • proc/ → Virtual filesystem providing process and kernel info
  • root/ → Home directory for the root (superuser)
  • run/ → Runtime process information since boot
  • sbin/ → System binaries (for admins, e.g., shutdown, fdisk)
  • srv/ → Data for services (FTP, web servers)
  • ys/ → Kernel and device information (virtual filesystem)
  • tmp/ → Temporary files (deleted at reboot)usr/ → User-installed software and applications
  • bin/ → Common user binaries
  • sbin/ → Non-essential system binaries
  • lib/ → Libraries for /usr/bin and /usr/sbin
  • share/ → Shared files, icons, docs
  • var/ → Variable data (logs, cache, spool, mail, DBs)

 / (Root): 

At the top of every Linux file system is the root directory represented by a forward slash /. It’s the base point, and no directory exists above it. If you look at the file system graphically, you’ll see all other directories branching from this root directory.

  • Every single file and directory start from the root directory.
  • The only root user has the right to write under this directory.
  • /root is the root user’s home directory, which is not the same as /

Only the root user has permission to modify contents inside this directory. Regular users cannot make changes here. For example, if you attempt to create a file in / as a non-root user, you’ll encounter a “Permission Denied” error.

2. /bin : 

The /bin directory contains essential commands and binaries needed by all users, including cplsssh, and kill. These commands are universally available across user types.

  • Contains binary executables.
  • Common linux commands you need to use in single-user modes are located under this directory.
  • Commands used by all the users of the system are located here e.g. ps, lspinggrepcp 

3. /boot :
This directory stores all files required for booting the system. It includes the GRUB bootloader configuration and essential kernel files that are loaded during startup.

  • Kernel initrd, vmlinux, grub files are located under /boot
  • Example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

4. /dev :

Device files in Linux are stored in the /dev directory. These are special files that act as interfaces between hardware and software. Device files are of two types: block devices (e.g., hard drives) and character devices (e.g., microphones and speakers). Examples include /dev/sda1 for disk partitions.

  • These include terminal devices, usb, or any device attached to the system.
  • Example: /dev/tty1, /dev/usbmon0

5. /etc :

Short for “Editable Text Configuration,” /etc contains configuration files for system applications, users, services, and tools or it contains the Host-specific system-wide configuration files. For example, user details like UID and local addresses are defined here.

  • This also contains startup and shutdown shell scripts used to start/stop individual programs.
  • Example: /etc/resolv.conf, /etc/logrotate.conf.

6. /home :

Every non-root user has a personal directory inside /home. For example, if your username is anshu, your personal directory would be /home/anshu. Each user can create, delete, or modify files only in their own home directory and cannot access others’ home directories.

  • Home directories for all users to store their personal files, containing saved files, personal settings, etc..
  • example: /home/kishlay, /home/kv

7. /lib:

Applications require shared libraries to run, which are stored in /lib. These include dynamic libraries needed during runtime. For example, Apache server libraries are available here.

  • Library filenames are either ld* or lib*.so.*
  • Example: ld-2.11.1.so, libncurses.so.5.7

8. /media:

Devices like USBs, CDs, and pen drives are mounted under /media. For example, when a CD-ROM is inserted (appeared in FHS-2.3), its details will appear here.

  • Temporary mount directory for removable devices.
  • Examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer

9. /mnt :

When external drives are connected, they are temporarily mounted in /mnt. This is where their contents become accessible to the system.

  • Temporary mount directory where sysadmins can mount filesystems.

10. /opt : 

Third-party software and packages not part of the default system installation are stored in /opt. It includes their configuration and data files.

  • Contains add-on applications from individual vendors.
  • Add-on applications should be installed under either /opt/ or /opt/ sub-directory.

11. /sbin : 

Essential system binaries, e.g.,

This directory holds administrative binaries like iptables, firewall management tools, fsck, init, route etc. These binaries are primarily for system administrators and typically require root privileges to execute.

  • Just like /bin, /sbin also contains binary executables.
  • The linux commands located under this directory are used typically by system administrators, for system maintenance purposes.
  • Example: iptables, reboot, fdisk, ifconfig, swapon

12. /srv : 

Site-specific data served by this system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems.

  • srv stands for service.
  • Contains server specific services related data.
  • Example, /srv/cvs contains CVS related data.

13. /tmp : 

Programs create temporary files during execution, and these are stored in /tmp. These files are deleted automatically after the program finishes or when the system is restarted.

  • Directory that contains temporary files created by system and users.
  • Files under this directory are deleted when the system is rebooted.

14. /usr : 

Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications. 

  • Contains binaries, libraries, documentation, and source-code for second level programs.
  • /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
  • /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
  • /usr/lib contains libraries for /usr/bin and /usr/sbin
  • /usr/local contains user’s programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2
  • /usr/src holds the Linux kernel sources, header-files and documentation. 

15. /proc:

The /proc directory provides detailed information about system processes. Each process is assigned a unique ID and represented as a directory inside /proc. For example, /proc/meminfo gives real-time data about memory usage including total, free, buffer, and cache statistics.

  • Contains information about system process.
  • This is a pseudo filesystem that contains information about running processes. For example: /proc/{pid} directory contains information about the process with that particular pid.
  • This is a virtual filesystem with text information about system resources. For example: /proc/uptime

 

Common Linux File System Types

File SystemDescriptionKey Features
ext2Older system (no journaling)Simple, used for small or boot partitions
ext3ext2 + journalingBetter recovery after crash
ext4Default in most LinuxFast, large file support, stable
XFSHigh-performanceGood for large data and databases
BtrfsAdvanced modern FSSnapshots, compression, RAID features
swapVirtual memory spaceUsed when RAM is full

Common Linux File System Commands

Command

Description

df -h

Show disk usage

du -sh /home

Show folder size

lsblk

List disks and partitions

fdisk -l

View disk partitions

mount

Mount devices

umount

Unmount devices

cat /etc/fstab

View mount configurations

ls -l

View file permissions

 

EXT2, EXT3, EXT4, and XFS file systems

1. EXT (Extended File System) Family

The EXT family is the most widely used Linux file system series.
It includes EXT2, EXT3, and EXT4, each one improving the previous version.


 

A. EXT2 (Second Extended File System)

Introduced: 1993
Developer: Rémy Card

 

Description:

  • EXT2 was one of the first native Linux file systems.

  • It does not have journaling, meaning if the system crashes, you must run fsck (file system check) to repair it.

 

Features:

  • No journaling (faster in some cases)

  • Supports large files (up to 2TB)

  • Simple and reliable structure

  • Commonly used for /boot partitions (where journaling is not needed)

 

Limitations:

  • Data loss risk on system crash or power failure

  • Slow recovery (needs manual check with fsck)

 

Use Case:

  • Boot partitions or small storage media (USB, SD cards)


 

 B. EXT3 (Third Extended File System)

Introduced: 2001
Developer: Stephen Tweedie

 

Description:

  • EXT3 = EXT2 + journaling feature

  • Journaling improves reliability and recovery speed after crashes.

 

Features:

  • Journaling support (logs all changes before applying them)

  • Backward compatible with EXT2 (you can upgrade EXT2 to EXT3)

  • Max file size: 2TB

  • Max file system size: 16TB

 

Journaling Modes:

  1. Journal mode – Logs both data and metadata (safest)

  2. Ordered mode (default) – Logs only metadata but writes data first

  3. Writeback mode – Fastest but less safe

 

Limitations:

  • Slower than EXT2 due to journaling overhead

  • Does not support file system defragmentation

  • Limited scalability for very large drives

 

Use Case:

  • General-purpose Linux systems where reliability is important.


 

 C. EXT4 (Fourth Extended File System)

Introduced: 2008
Developer: Theodore Ts’o

 

Description:

  • EXT4 is the default file system for most modern Linux distributions (Ubuntu, Debian, Fedora, RHEL).

  • Backward compatible with EXT3 and EXT2.

 

Features:

  • Supports very large files and volumes

    • Max file size: 16TB

    • Max filesystem size: 1 exabyte (EB)

  • Journaling with checksums for reliability

  • Extents: stores files in contiguous blocks → faster performance

  • Delayed allocation: improves write performance

  • Multiblock allocation: allocates multiple blocks at once

  • Backward compatible with EXT3/EXT2

  • Online defragmentation supported

 

Advantages:

  • Very fast and stable

  • Efficient storage for both small and large files

  • Less fragmentation

  • Quick recovery after power failure

 

Limitations:

  • No built-in snapshot feature

  • Not ideal for complex volume management (use LVM or Btrfs for that)

 

 Use Case:

  • Default choice for desktop, server, and enterprise Linux systems.


 

2. XFS File System

Introduced: 1994 by SGI (Silicon Graphics Inc.)
Default in RHEL (Red Hat Enterprise Linux)


 

Description:

XFS is a high-performance 64-bit journaling file system designed for large files and parallel I/O (input/output).

It’s especially good for servers, databases, and multimedia storage systems.


 

 Features:

  • Journaling file system for fast recovery

  • High scalability (up to 8 exabytes)

  • Extents-based allocation (stores large files in contiguous blocks)

  • Delayed allocation (improves performance)

  • Online resizing (you can expand mounted partitions)

  • Metadata journaling

  • Parallel I/O (uses multiple CPU cores for better speed)

  • Quota management (limit user disk usage)


 

 

 Advantages:

  • Excellent for large files and high-performance applications

  • Fast file creation/deletion

  • Efficient with multi-terabyte storage

  • Great for enterprise servers, backups, and media workloads


 

Limitations:

  • Cannot shrink partitions (only expand)

  • Not ideal for many small files (higher metadata overhead)

  • Slightly more complex to manage than EXT4


 

Use Case:

  • Enterprise servers, NAS (Network Attached Storage), and systems that handle large files, databases, or video editing.

 

3. Comparison Table: EXT2 vs EXT3 vs EXT4 vs XFS

FeatureEXT2EXT3EXT4XFS
Journaling❌ No✅ Yes✅ Yes✅ Yes
Max File Size2 TB2 TB16 TB8 EB
Max Volume Size32 TB16 TB1 EB8 EB
SpeedFast (no journal)ModerateVery FastVery Fast (especially for large files)
Data SafetyLowHighVery HighVery High
Backward CompatibleN/AEXT2EXT3/EXT2No
Ideal UseSmall partitions, bootGeneral purposeDefault for allServers, media, databases
Developed1993200120081994 (SGI)
Supports Extents❌ No❌ No✅ Yes✅ Yes
Online Resize❌ No✅ Limited✅ Yes✅ Expand only
Defragmentation❌ No❌ No✅ Yes✅ Yes

Linux file system and the Windows file system

Overview

FeatureLinux File SystemWindows File System
Common Typesext2, ext3, ext4, XFS, BtrfsFAT32, exFAT, NTFS
StructureSingle root hierarchy (/)Multiple drives (C:\, D:\)
Case SensitivityCase-sensitive (File.txtfile.txt)Case-insensitive (File.txt = file.txt)
File PermissionsOwner, Group, Others (rwx)ACL (Access Control List) and user permissions
Journalingext3, ext4, XFS support journalingNTFS supports journaling
Default File Systemext4NTFS
Hidden FilesStart with a dot (.file)Have “hidden” attribute
SecurityStrong permission-based, multi-userACL-based, user access control (UAC)
Symbolic LinksFully supportedSupported in NTFS (from Windows Vista+)
MountingDevices mounted under /mnt or /mediaDrives automatically labeled (C:, D:, etc.)

2. File System Structure

Linux Structure

  • Everything is under a single root (/).

  • Example:

				
					/
├── bin/
├── etc/
├── home/
├── var/
├── usr/
└── tmp/

				
			

Windows Structure

  • Uses drive letters (each partition is a separate tree):

				
					C:\
├── Program Files
├── Users
├── Windows
D:\
└── Data

				
			

3. Common File Systems

LinuxWindowsDescription
ext2FAT16Older, no journaling
ext3FAT32Journaling (Linux), simple but limited (Windows)
ext4NTFSModern, supports large files
XFS / BtrfsexFAT / ReFSHigh-performance or enterprise-grade

4. File System Features Comparison

FeatureLinux (ext4/XFS/Btrfs)Windows (NTFS/exFAT)
Maximum File SizeUp to 16TB (ext4), 8EB (XFS)Up to 16EB (NTFS)
JournalingYes (ext3/ext4/XFS)Yes (NTFS)
CompressionSupported in BtrfsSupported in NTFS
SnapshotsBtrfs, ZFS support snapshotsReFS supports snapshots
EncryptioneCryptfs, LUKSBitLocker (drive-level)
DefragmentationRarely neededRegularly needed for HDDs
PerformanceOptimized for multitasking & serversOptimized for desktop workloads
ReliabilityVery high (journaling, permissions)High (journaling)
 

5. Performance and Usage

PurposeLinux (ext4/XFS/Btrfs)Windows (NTFS/exFAT)
Servers / DatabasesExcellent (XFS, ext4, Btrfs)Moderate (NTFS)
Desktop UseVery goodExcellent
GamingModerateBest (Windows)
Virtualization / CloudVery strongLimited native tools
File RecoveryWith fsck, testdiskWith chkdsk, Recovery tools

10. Summary Table

FeatureLinux File SystemWindows File System
Root Directory/C:\
Case SensitivityYesNo
Default Typeext4NTFS
Partition MountManual or auto mountDrive letters
SecurityUser & group-based, SELinuxACL & BitLocker
SpeedFast for multitaskingFast for single-user desktop
Data Recoveryfsck, journalingchkdsk, journaling
Best ForServers, developers, security-focused usersGeneral users, business desktops