What is the current Linux file system used to hold the operating system?

Linux File System Structure (Image created by the author | Icon credits: PNGWing)

File systems are standards for organizing data on storage devices. A file system divides the storage space on a drive into virtual compartments known as clusters. It also maintains an index of where each file is located and where free space is available.

In this article, we will discuss the different file system types, the directory structure within the file system, and a few commands for navigating and performing different operations on the file system.

File System Types

Linux supports various file system types, and we will discuss some important ones below.

Ext

The extended file system (ext) was launched for Linux in 1992 and is the first file system designed specifically for Linux. It was designed partly based on the UNIX file system. The purpose of its creation was to innovate beyond the file system being used then (MINIX file system) and overcome its limitations. This file system allows a file size of up to 2 GB and a volume size of 2 GB.

Ext2

The second extended file system (ext2) was created in 1993 to be a successor to the original ext file system for Linux. It had improvements in areas such as storage capacity and general performance. It was for many years default for many Linux distributions. This file system allows a file size of up to 2 TB and volume size of 32 TB.

Ext3

The third extended system (ext3), created in 2001, surpasses ext2, and it is a journaling file system. A journaling file system is a system that records the changes and updates in the data at different stages. Journaling is used to repair and restore the data to its previous state upon reboot, in case your computer or hard disk(s) crashes or you face a power failure. This file system allows a file size of up to 2 TB and volume size of 32 TB.

Ext4

The fourth extended system (ext4) was created in 2008. Since this file system overcomes numerous limitations that the ext3 had, it’s both widely used and the default file system that most Linux distributions use. This file system allows a file size of up to 16 TB and volume size of 1 EB.

JFS

The Journaled File System (JFS) was first created by IBM in 1990 and later taken to open source for implementation for Linux in 1999. And as we have discussed in ext3, this is also a journaling file system that uses records on updates in the file system to repair and restore data. It can also be used as an alternate for ext4, where we need stability with few resources because it uses less CPU power than the other file systems. This file system allows a file size of up to 4 PB and a volume size of 32 PB.

ReiserFS

The ReiserFS is a journaling file system developed in 2001 and is an alternate to ext3. It uses a B+ Tree that gives it less than linear time in directory lookups and updates. It was the default file system for SUSE Linux till it was switched to ext3 in 2006 due to some policy changes. This file system allows a file size of up to 8 TB and a volume size of 16 TB.

XFS

The Extend File system (XFS) was created by Silicon Graphics in 1990 but later given to Linux in 2001. XFS is a 64-bit high-performance journaling file system developed for parallel I/O processing. It provides many features like snapshots, online defragmentation, sparse files, and variable block sizes. It is particularly noteworthy for how incredibly well it works with large files, contrarily not the best with smaller files. And NASA is still using this file system with its high storage server (300+ Terabyte servers). This file system allows a file size of up to 8 EB and volume size of 8 EB.

BTRFS

The B Tree File System (BTRFS) was created by Oracle in 2009. It is used for fault tolerance, repair system, extensive storage configuration, and much more. But, it is not a good suit for a production system. It provides many features like snapshotting, drive pooling, data scrubbing, self-healing, and online defragmentation. And it is the default file system for Fedora Workstations. This file system allows a file size of up to 16 EB and volume size of 16 EB.

SWAP

The swap file system is not exactly a file system but reserved disk space used for memory paging in Linux operating system during the system hibernation. A system that never goes to hibernate state requires a swap space equal to its RAM size.

Directory Structure

The Linux File system has a hierarchal file system structure for directories defined by FileSystem Hierarchy Standard(FSHS). It looks like an inverted tree with root (/) at the highest level and all the other directories and subdirectories branching out from the root level.

At the root level, you can find different directories, which have specific purposes and hold the files necessary for running the OS and performing various operations on the operating system.

How many and what directories are present at the root level will vary with different distributions of Linux. So, here we will see the most common directories that you would see on most distributions.

/boot

This directory contains the files needed for booting the Operating System (OS). A few examples are Basic Input/Output System (BIOS), Linux kernels, Master Boot Record (MBR) boot loader, and many other files.

The BIOS checks the integrity of the hard disk(s) in the system then it executes the Master Boot Record (MBR) boot loader.

Although all the booting-related files rest in /boot directory, the configuration files are not stored here but in the /etc directory.

/etc

As we discussed above, the configuration files for booting and all the different programs that run on the OS are in the/etcdirectory. You can also edit these files as you need.

Basically, you can find different configuration files in the /etcdirectory, including the system configuration files and config files for all the programs you install and use on the OS.

/bin

This directory contains the core system executables (programs) and utilities. For example, very well-known and commonly used commands such as cd, ls, and cat are in the /bindirectory. These files are available to all users.

/sbin

The /sbin directory is very similar to /bin, as it contains core system administration executables (programs) and utilities, usually for system administration. So, these files are only available to the root users. A few examples are fdisk and ifconfig utilities.

/lib

Each program or binary uses specific libraries to function, and all the shared libraries are in the /lib directory. This directory in sometimes also contains kernel-related files based upon the distribution.

/home

The /home directory contains a home folder for every user on your system. These folders are named using the user names.

For example, if the user name is joe, the home folder for the user would be /home/joe.

These individual home folders contain the user data files and configuration files, that are specific to a user, which need to be stored elsewhere besides in the /etc directory that we discussed earlier.

If one user wants to modify files of other users on a system, they must become the root user, as each user only has “write” permissions for their own home folder.

/usr

The /usr directory stores read-only data, including the executable binaries, libraries, and the other files shared between multiple users.

The /usr directory has its own /bin and /sbin directories that store binaries that are non-essential to OS and intended for the end-user.

There is a /local directory inside /usr which in turn has its own /bin and /sbin directories, these contain the binaries that the users compile manually and are kept here not to have any conflict with the system binaries.

/dev

Linux displays all connected devices as directories/files, and the /dev directory contains all those directories/files. Though all things you see here are hardware, these are the device driver files needed for accessing and using those connected devices. It is also where you can mount and see the physical drives.

/tmp

The /tmp directory stores temporary files created by different programs in the system which get deleted when the system restarts. And if you manually want to remove temporary files, you can use the tmpwatch utility. The tmpwatch command recursively removes files that haven’t been accessed for a given amount of time.

/proc

The /proc directory is a directory that is very similar to the /dev directory that we discussed earlier. These are the particular files that are actually kernel and process pseudo files which are shown as directories. These directories or files are marked by process number or other information which is dynamic to the system.

/var

The /var directory is like the /usr directory, but instead of being read-only, it is writable and is used to store system logs, print files, and any other files which could have a variable amount of data.

/opt

The /opt directory holds the subdirectories where optional software packages are located and managed by the package manager.

Few Commands to work with the file system

You can explore and perform different operations in the filesystem, below are a few commands related to files, directories, navigation, and performing other operations on the file system that you can use.

The cd <path> takes you to the directory that you have specified. If you use cd without a path, it will take you to your home directory. You can move a level up from the current location using cd .. command.

The pwd command which is present working directory shows you the current directory you are in.

The ls command allows you to list the contents at the current location, or you can provide a path to list the contents.

The tree <path> will list all the directories and contents in the given path in a tree format.

The dfis to get a ballpark estimate of how much space is used on the file system.

The du <path> one other hand gets you more accurate details about space and many other details about the files and directories at the given path.

The find path expression term allows you to locate a given term in the given path based on a given user expression.

The file <file name> is used to know the type of the given file.

The cat name name2 is generally used to display the contents of one or more files without having to open those files for editing.

The mkdir <path with name> allows you to create a new directory at the given path with the given name.

The rm <path with name>is used to remove the file for the given name from the given path.

The rmdir <path with name> allows you to delete the directory at the given path with the given name.

The touch <file name>command is used to create a file if it doesn’t exist already. But its primary function is not, but to change the modification and access time for any given file.

The whereis <command name>allows you to find the location of the binary, source, and manual page files for a given command.

The which <file name>is to find the location of the given executable command from the list of directories specified in the PATH environment variable.

These were a few things like what a file system is, different types of file systems for Linux, the directory structure within the file system, and a few commands to navigate and perform operations on files and directories in the file system. Hope you have found them useful.

Thanks for reading, and happy learning!

If you enjoy reading stories like these and want to support me as a writer, consider signing up as a Medium member. It’s $5 a month, giving you unlimited access to all the stories on Medium. If you sign up using my link, I’ll earn a small commission.

What is the current Linux file system?

Most of the recent Linux distributions use Ext4 file system which is modern and upgraded version of older Ext3 and Ext2 file systems. Reason behind most of the Linux distributions use Ext4 file systems is that it is one of the most stable and flexible file systems out there.

What is the file system used in the operating system?

A file system in an operating system decides the way the contents of its storage medium (secondary memory, etc) are stored and organized. Examples of filesystems are btrfs, xfs, zfs, ext series, ntfs, etc. These filesystems differ in aspects of implementation, use cases, etc.

Which is the most likely used file system in Linux?

Ext4 is the default file system on most Linux distributions for a reason. It's an improved version of the older Ext3 file system.