Linux File System
Operating Systems, the software that powers your computer, rely on a crucial element known as the file system.
A file system defines how data is named, stored, organized, and retrieved on a storage device.
In the Linux world, a diverse range of file systems has emerged, each designed to address specific needs - from simple USB drives to massive enterprise storage arrays.
Inside the operating system, file handling is organized into three layers that work together:
At the top, the Logical File System is the interface that user applications talk to, handling operations like opening, reading, writing, and closing files.
In the middle, the Virtual File System [VFS] provides one standard interface, so many different file systems [ext4, XFS, NTFS, USB drives, network shares] can be used at the same time.
At the bottom, the Physical File System manages the actual data blocks on the disk, deciding where data is stored and how it is retrieved.
Linux File System Structure:
A file system mainly consists of 3 layers. From top to bottom:
Logical File System:
The Logical File System is the interface between user applications and the file system itself.
It receives requests from programs [through system calls such as open(), read(), write(), and close()], checks permissions, and keeps track of open files.
Applications never need to know how or where the data is physically stored - they simply ask for a file by its name and path.
Virtual File System:
The Virtual File System [VFS] is an abstraction layer inside the Linux kernel.
It provides one common interface for every file system, so the same commands [ls, cp, cat] work the same way on an ext4 partition, a FAT32 USB drive, an NFS network share, or a virtual file system like /proc.
This is what allows many different file systems to be mounted and used at the same time within a single directory tree.
Physical File System:
The Physical File System is responsible for the actual management and storage of data blocks on the disk.
It handles the low-level details of allocating space, writing and reading blocks, and working with the storage device driver.
This is the layer where the differences between ext4, XFS, btrfs, and other file systems really show - in how they lay out data, handle crashes, and use storage space efficiently.
Characteristics of a File System:
Space Management - How data is stored on a storage device, including how blocks are allocated and how fragmentation is handled.
Filename - A file system may have restrictions on file names, such as the maximum length, which special characters are allowed, and whether names are case-sensitive [Linux file systems are case-sensitive, so File.txt and file.txt are two different files].
Utilities - File systems provide features for creating, deleting, renaming, moving, copying, backing up, recovering, and controlling access to files and folders.
Directory - Directories [folders] organize files in a hierarchical tree, and keep an index of all the files they contain.
Metadata - For each file, the file system stores information about the file itself, such as its size, owner, access permissions, file type, and timestamps [created, modified, accessed]. This is called metadata.
Some important terms:
Journaling - Before making changes to the disk, the file system first writes a record of the intended changes to a log called the journal.
If the system crashes or loses power in the middle of a write, the file system can replay or discard the journal entries on the next boot,
and quickly return to a consistent state instead of scanning the entire disk.
Copy-on-Write [CoW] - Instead of overwriting data in place, the file system writes the new version to a new location and then updates the pointers.
This protects against corruption during crashes and makes features like snapshots almost free [used by btrfs, bcachefs, and ZFS].
Snapshots - A read-only or writable copy of the file system's state at a specific point in time, which can be used for backups or to roll back changes.
Inode - The index node is a data structure that stores a file's metadata: its type, size, owner, permissions, timestamps, and pointers to the data blocks on the disk.
The inode does not store the file name - names are stored in directories, which map each name to an inode number.
You can see a file's inode number with ls -i, and its full inode information with the stat command.
Now let's dive into the different file systems Linux uses for disk storage devices.
Types Of Linux File Systems:
ext [Extended File System] - Released in 1992, it was the first file system specifically designed for Linux, and the first member of the ext family.
It was quickly replaced by ext2 and was removed from the kernel in 1997.
ext2 - The second extended file system was released in 1993. It is a non-journaling file system.
It added separate timestamps for file access, inode modification, and data modification, which the original ext lacked.
Because it has no journal, an unclean shutdown forces a full file system check [fsck] at the next boot, which can take a very long time on large disks.
ext2 was once recommended for flash drives to reduce the number of writes, but modern SSDs handle journaling without problems, and ext4 is the better choice today.
ext2 is still occasionally used for very small partitions, such as /boot.
Xiafs - Also released in 1993 as a competitor to ext2, it was less powerful and less flexible, and was removed from the kernel in 1997.
ext3 - The third extended file system added journaling to ext2, and was merged into the Linux kernel in 2001.
Thanks to the journal, it avoids the long file system checks at boot after an unclean shutdown.
It also added online file system growth and HTree indexing for directories with many files, and an existing ext2 file system can be converted to ext3 without reformatting.
Since kernel 4.3 [2015], ext3 file systems are handled by the ext4 driver.
JFS [Journaled File System] - Originally created by IBM in 1990 for its AIX operating system, JFS was released as open source and ported to Linux around 1999 - 2001.
JFS performs well under different kinds of load and uses little CPU, but it is rarely used today, and receives only minimal maintenance in the kernel.
ReiserFS - A journaling file system that was merged into the Linux kernel in 2001, making it the first journaling file system available in mainline Linux.
It used a B+ Tree structure for fast directory lookups, and a technique called tail packing to store small files efficiently and reduce wasted space.
It was the default file system in SUSE Linux starting with version 6.4, until SUSE switched to ext3 in 2006.
After years without active maintenance [and unresolved issues such as the Year 2038 problem], ReiserFS was deprecated in 2022 and removed from the Linux kernel in version 6.13 [2025].
XFS - A 64-bit, high-performance journaling file system originally created by SGI in 1993, and ported to Linux in 2001.
It is the default file system for Red Hat Enterprise Linux [RHEL] since version 7, and its derivatives such as Rocky Linux, AlmaLinux, and CentOS Stream.
It supports very large files and volumes, online defragmentation, online growth, sparse files, delayed allocation, and it excels at parallel I/O on large servers.
XFS cannot be shrunk, and it does not have native snapshots [snapshots are usually done with LVM underneath it].
SquashFS - Released in 2002, SquashFS is a compressed, read-only file system.
It is used wherever a compact, unchangeable image is needed: Live USB/CD images, Snap packages, AppImages, and firmware for routers and embedded devices.
Reiser4 - Released in 2004 as the successor to ReiserFS, with a plugin-based design that added features like compression and encryption.
It was never merged into the mainline Linux kernel, and its development has effectively stopped.
ext4 - The fourth extended file system started development in 2006 and became stable in 2008. It is a journaling file system.
It is backward compatible - ext3 and ext2 file systems can be mounted as ext4.
It added extents [storing large files as continuous block ranges], delayed allocation, persistent pre-allocation, an unlimited number of subdirectories,
metadata checksums, native per-directory encryption [fscrypt], and support for much larger files and volumes.
ext4 is the default file system for many Linux distributions, including Debian, Ubuntu, and Linux Mint.
Note: Windows and macOS cannot read ext4 natively. Accessing it requires third-party tools, or on Windows, mounting the disk through WSL [wsl --mount].
btrfs [B-tree FS, pronounced "Butter FS" or "Better FS"] - Development started in 2007, and it was merged into the Linux kernel in 2009.
btrfs is a copy-on-write file system that provides snapshots, subvolumes, transparent compression, data and metadata checksums, self-healing, scrubbing,
built-in RAID [0, 1, 10], drive pooling, online defragmentation, and send/receive for efficient backups.
It is the default file system for Fedora Workstation [since Fedora 33] and openSUSE.
Note: btrfs RAID 5/6 is still not considered stable for production use.
bcachefs - A copy-on-write file system first announced in 2015, with the goal of combining the features of btrfs with the performance and reliability of ext4 and XFS.
Its features include full file system encryption, native compression, snapshots, checksums, and caching across fast and slow drives [SSD + HDD].
bcachefs was merged into the Linux kernel in version 6.7 [2024], but was removed again in version 6.18 [2025], and is now distributed as a separately installed module [DKMS].
Others - Linux also supports file systems from other operating systems, such as NTFS [Windows], FAT32 and exFAT [USB drives and SD cards], and HFS+ [older macOS].
These do not store standard Unix permissions and ownership, so they are mostly used for sharing data with other operating systems.
ZFS is also widely used on Linux [through OpenZFS], but because of licensing differences, it is distributed separately from the kernel.
The table below compares Linux file systems on several key criteria. Please note that there are more criteria than the ones listed in the table.
This table is supposed to give you an idea of how file systems have evolved. Size limits depend on the block size used when the file system was created.
| File System |
ext |
ext2 |
Xiafs |
ext3 |
JFS |
ReiserFS |
XFS |
Reiser4 |
ext4 |
btrfs |
| Status Today |
Removed [1997] |
Supported |
Removed [1997] |
Supported [via ext4 driver] |
Supported [minimal maintenance] |
Removed [kernel 6.13, 2025] |
Supported |
Never merged |
Supported |
Supported |
| Max. filename length [bytes] |
255 |
255 |
248 |
255 |
255 characters |
4032 [255 under Linux] |
255 |
3976 [255 under Linux] |
255 |
255 |
| Allowable characters in directory entries |
Any byte except NUL and / |
Any byte except NUL and / |
Any byte except NUL and / |
Any byte except NUL and / |
Any Unicode except NUL and / |
Any byte except NUL and / |
Any byte except NUL and / |
Any byte except NUL and / |
Any byte except NUL and / |
Any byte except NUL and / |
| Max. pathname length |
Undefined |
Undefined |
Undefined |
Undefined |
Undefined |
Undefined |
Undefined |
Undefined |
Undefined |
Undefined |
| Max. file size |
2 GB |
16 GB – 2 TB |
64 MB |
16 GB – 2 TB |
4 PB |
8 TB |
8 EB |
8 TB [on x86] |
16 GB – 16 TB |
16 EB |
| Max. volume size |
2 GB |
2 TB – 32 TB |
2 GB |
2 TB – 32 TB |
32 PB |
16 TB |
8 EB |
- |
1 EB |
16 EB |
| Max. no. of files |
- |
- |
- |
- |
- |
- |
2^64 |
- |
2^32 |
2^64 |
| Journaling |
No |
No |
No |
Yes [metadata by default, full data optional] |
Yes [metadata] |
Yes [metadata] |
Yes [metadata] |
Yes [atomic transactions] |
Yes [metadata by default, full data optional] |
Not needed [copy-on-write] |
| Compression |
No |
No |
No |
No |
No |
No |
No |
Yes [plugin] |
No |
Yes [zlib, LZO, zstd] |
| Block sub-allocation |
No |
No |
No |
No |
Yes |
Yes [tail packing] |
No |
Yes |
No |
Yes |
| Online grow |
No |
No |
No |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
| Encryption |
No |
No |
No |
No |
No |
No |
No |
Yes [plugin] |
Yes [fscrypt] |
No [use LUKS/dm-crypt] |
| Checksum |
No |
No |
No |
No |
No |
No |
Metadata only |
No |
Metadata only |
Yes [data and metadata] |
Linux Directories:
Unlike Windows, Linux has no drive letters. Everything lives in a single directory tree that starts at the root directory [/],
and every disk, partition, USB drive, or network share is attached [mounted] somewhere inside that tree.
The layout of this tree follows the Filesystem Hierarchy Standard [FHS], so the main directories are the same on almost every Linux distribution.
/bin
Contains binaries - the essential commands and programs every user can run, such as ls, cp, mv, rm, cat, and bash.
There are more bin directories in other parts of the file system tree [such as /usr/bin and /usr/local/bin], which we'll cover below.
On most modern distributions, /bin is simply a link to /usr/bin [see /usr].
/boot
Contains the files required to start your system: the Linux kernel [vmlinuz], the initial RAM disk [initrd/initramfs], and the bootloader files [GRUB].
If you damage one of the files in here, your system may not boot, and it can be a pain to repair - so DO NOT TOUCH unless you know exactly what you are doing.
Fortunately, you need superuser privileges to change anything here, so it is hard to break it by accident.
/dev
Contains device files. In Linux, "everything is a file" - including hardware.
For example, /dev/sda is your first disk, /dev/sda1 is its first partition, /dev/null discards everything written to it, and /dev/urandom produces random data.
Many of these entries are created at boot time or on the fly - plug in a USB drive or webcam, and a new device entry will appear here automatically.
/etc
The name /etc comes from the earliest versions of Unix, where it literally meant "et cetera" - the place for system files that didn't belong anywhere else.
Today it holds most, if not all, system-wide configuration files [a popular way to remember it is "Everything To Configure"].
For example, the files that define your system's hostname, user accounts, network settings, DNS servers, and which partitions get mounted at boot are all in here.
If you are new to Linux, it is best to be careful in here until you have a better understanding of how things work.
From a security perspective, /etc is one of the first places attackers look during enumeration [user accounts, SSH settings, cron jobs, and sudo rules].
System Configuration Files
| Configuration Files |
Description |
| /etc/bashrc |
System-wide settings and aliases for the bash shell [on Debian/Ubuntu: /etc/bash.bashrc]. |
| /etc/crontab |
The system-wide cron table - defines commands that run automatically at scheduled times [additional jobs live in /etc/cron.d/]. |
| /etc/exports |
Lists the directories shared with other machines over NFS [Network File System]. |
| /etc/fstab |
The file system table - lists the disks and partitions and where they are mounted at boot. |
| /etc/group |
Defines user groups and their members. |
| /etc/default/grub |
GRUB2 bootloader settings [the generated configuration is /boot/grub/grub.cfg; /etc/grub.conf was used by legacy GRUB]. |
| /etc/hostname |
The name of the system. |
| /etc/hosts |
Maps IP addresses to hostnames locally, checked before DNS. |
| /etc/hosts.allow & /etc/hosts.deny |
Lists of hosts allowed or denied access to services through TCP Wrappers [legacy - removed from many modern distributions]. |
| /etc/init.d |
Service startup scripts for the SysV init system [legacy - modern distributions use systemd units]. |
| /etc/inittab |
Configured the SysV init process and its run levels [legacy - not used by systemd]. |
| /etc/issue |
The message shown before login on local terminals [/etc/issue.net for remote logins]. |
| /etc/modprobe.d/ |
Configuration for loading kernel modules [replaced the older /etc/modules.conf]. |
| /etc/motd |
The "Message Of The Day", shown to users after they log in. |
| /etc/mtab |
Lists the currently mounted file systems [on modern systems, a link to /proc/self/mounts]. |
| /etc/passwd |
Lists user accounts: username, UID, GID, home directory, and login shell. Readable by everyone. The password field contains only an "x" - the real password hashes are in /etc/shadow. |
| /etc/shadow |
Stores the hashed user passwords and password-aging settings. Readable only by root. |
| /etc/sudoers |
Defines which users and groups can run commands as root with sudo [always edit with visudo; extra rules live in /etc/sudoers.d/]. |
| /etc/ssh/sshd_config |
Configuration of the SSH server [allowed users, root login, password or key authentication]. |
| /etc/profile |
System-wide environment and startup settings for login shells. |
| /etc/profile.d/ |
Additional scripts that run for every user at login. |
| /etc/rc.d/ |
Directory holding the SysV init run level scripts on older Red Hat-based systems [legacy]. |
| /etc/resolv.conf |
The DNS servers the system uses [often managed automatically by NetworkManager or systemd-resolved]. |
| /etc/security/ |
Configuration for PAM security modules, such as user resource limits [limits.conf] and access rules. |
| /etc/skel/ |
A template directory - its contents [such as .bashrc and .profile] are copied into the home directory of every new user. |
| /etc/systemd/system/ |
Custom and enabled systemd service units. |
| /etc/X11/ |
Configuration files for the X Window System. |
/home
Where you will find your users' personal directories, for example /home/adam.
Each user's personal settings are stored here too, in hidden files and folders that start with a dot [such as .bashrc, .ssh, and .config].
The shortcut ~ always points to the current user's home directory.
/lib
Where libraries live. Libraries are files containing shared code that applications can use, so every program doesn't have to include its own copy.
This directory also contains the kernel modules [/lib/modules] - the drivers that make things like your video card, sound card, WiFi, and printer work.
On 64-bit systems, you may also see /lib64. On most modern distributions, /lib is a link to /usr/lib.
/media
Where removable storage [USB drives, external disks, SD cards] is automatically mounted when you plug it in,
usually under a path like /media/username/DriveName.
/mnt
A place for temporarily mounting storage devices or partitions manually, for example: sudo mount /dev/sdb1 /mnt.
It is commonly used by administrators for maintenance, recovery, and forensics work.
/opt
Used for optional, self-contained third-party software packages that don't follow the standard Linux layout,
for example /opt/google/chrome or a commercial security tool. Each application usually gets its own subdirectory with everything it needs inside.
Software you compile and install yourself usually goes into /usr/local instead [/usr/local/bin, /usr/local/lib], where the package manager will not overwrite it.
/proc
A virtual directory - nothing in it is stored on the disk. The kernel generates its contents on the fly, as a live view into the running system.
It contains information about your hardware [CPU, memory], the kernel, and every running process - each process has its own folder named after its Process ID [PID], such as /proc/1234.
Tools like ps, top, and free get their information from /proc.
Virtual and Pseudo Process Related Files
| Virtual and Pseudo Process Related Files |
Descriptions |
| /proc/cpuinfo |
Information about the CPU [model, cores, speed, supported features]. |
| /proc/filesystems |
Lists the file system types supported by the running kernel. |
| /proc/interrupts |
Shows the number of interrupts per IRQ, for each CPU. |
| /proc/ioports |
Lists the I/O port address ranges used by devices on the system. |
| /proc/meminfo |
Reports memory usage information [total, free, cached, swap]. |
| /proc/modules |
Lists the kernel modules currently loaded [the same information as lsmod]. |
| /proc/mounts |
Lists the currently mounted file systems. |
| /proc/stat |
Detailed statistics about the system [CPU time, processes, context switches]. |
| /proc/swaps |
Lists the swap partitions and swap files in use. |
| /proc/version |
The running kernel version [the same information as uname -a]. |
| /proc/[PID]/ |
A folder for each running process, including its command line [cmdline], environment variables [environ], and open files [fd]. |
/root
The home directory of the superuser [root], the administrator of the system.
It is kept separate from the other users' home directories in /home, and only root can access it.
Keep your own files in your own home directory.
/run
A newer directory [introduced in 2011] that holds temporary runtime data for system processes, such as process ID files [.pid] and sockets.
It is stored in memory [tmpfs], so its contents are cleared on every reboot. This is another one of those DO NOT TOUCH folders.
/sbin
Similar to /bin, but it contains system administration commands that usually require superuser privileges [hence the "s" for system].
Examples include fdisk, mkfs, ip, reboot, and iptables. You run them with the sudo command, which temporarily gives you superuser powers.
Many of these tools can format disks, delete data, or change the network configuration, so handle with care.
On most modern distributions, /sbin is a link to /usr/sbin.
/usr
In the early days of Unix, /usr was where users' home directories were kept. Today, /home is used for that,
and /usr contains most of the installed software: applications, libraries, documentation, man pages, icons, and other shared data.
You will also find bin, sbin, and lib directories inside /usr. What is the difference from their cousins directly under /?
Originally, /bin held only the essential commands needed to boot and repair the system [like ls, mv, and rm], while /usr/bin held everything else.
This split made sense when /usr was often on a separate disk, but today it no longer serves a purpose.
That's why most modern distributions use a "merged /usr" layout: all programs are stored in /usr/bin, and /bin, /sbin, and /lib are just links pointing into /usr.
This includes Fedora, Arch Linux, Ubuntu [since 19.04], Debian [since version 12], and Linux Mint.
| User Related Files |
Descriptions |
| /usr/bin |
Contains most of the executable programs on the system. |
| /usr/sbin |
Contains system administration commands, usually run by the superuser. |
| /usr/lib |
Contains libraries and internal files used by programs. |
| /usr/include |
Contains header files used when compiling C and C++ programs. |
| /usr/share |
Contains architecture-independent shared data, such as documentation, man pages, icons, and wallpapers. |
| /usr/local |
Contains software installed manually by the administrator [not by the package manager], with its own bin, lib, and share folders. |
| /usr/bin/X11 |
A legacy symbolic link that points back to /usr/bin, kept for compatibility with old X Window System paths. |
/srv
Contains data served by the system to others. If you are running a web server, your website files could go into /srv/http or /srv/www,
and if you were running an FTP server, your files could go into /srv/ftp.
Note that many distributions use /var/www for web servers by default instead.
/sys
Another virtual directory like /proc. It exposes information about the kernel, drivers, and the devices connected to your computer.
In some cases you can also change device settings by writing to these files - for example, changing a laptop's screen brightness through a file such as
/sys/class/backlight/intel_backlight/brightness [the exact path will be different on your machine].
Doing this requires superuser privileges, because writing the wrong values in /sys can make your system unstable. DO NOT TOUCH until you are sure you know what you are doing.
/tmp
Contains temporary files created by applications and users.
On many distributions /tmp is stored in memory [tmpfs] or cleaned automatically, so its contents are deleted on reboot - never keep anything important here.
/tmp is writable by every user, but it has the sticky bit set [drwxrwxrwt], which means users can only delete their own files.
From a security perspective, /tmp [and /dev/shm] are common places for attackers to drop and run malicious files, because every user can write there.
/var
Its name comes from "variable", because its contents change frequently while the system is running.
It contains logs [/var/log], application data and databases [/var/lib], cached files [/var/cache], and spools - queues of tasks waiting to be processed,
such as print jobs or emails waiting to be delivered [/var/spool].
Logs are files that record events happening on the system - if a service fails, a user logs in, or someone tries to break in, it will be recorded in /var/log.
For a SOC analyst or incident responder, /var/log is often the first place to look.
Your system may have some more directories we haven't mentioned above. For example, Ubuntu systems have a /snap directory, which contains the software installed as Snap packages.
| Log Files |
Descriptions |
| /var/log/syslog |
General system messages on Debian/Ubuntu. |
| /var/log/messages |
General system messages on Red Hat-based systems [RHEL, Fedora, Rocky]. |
| /var/log/auth.log |
Authentication events on Debian/Ubuntu - logins, SSH connections, sudo usage, and failed password attempts. |
| /var/log/secure |
Authentication events on Red Hat-based systems [the equivalent of auth.log]. |
| /var/log/kern.log |
Kernel messages [also available with the dmesg command]. |
| /var/log/lastlog |
Stores each user's most recent login [binary file - read it with the lastlog command]. |
| /var/log/wtmp |
History of all logins, logouts, and reboots [binary file - read it with the last command]. |
| /var/log/btmp |
History of failed login attempts [binary file - read it with sudo lastb]. |
| /var/log/journal/ |
The systemd journal - binary logs from all services, read with the journalctl command. |
Credits: The Linux Directories section is partly based on
"The Linux Filesystem Explained" by Paul Brown [Linux.com / The Linux Foundation].
▲
▼