Linux File System

Nagesh Jadhav
7 min readDec 5, 2021

--

A Linux file system is a structured collection of files on a disk drive or a partition. A partition is a segment of memory and contains some specific data. In our machine, there can be various partitions of the memory. Generally, every partition contains a file system. A Linux file system is generally a built-in layer of a Linux operating system used to handle the data management of the storage. It helps to arrange the file on the disk storage. It manages the file name, file size, creation date, and much more information about a file.

Directory Structure

Linux file system has a hierarchical file structure as it contains a root directory and its sub-directories. All other directories can be accessed from the root directory. A partition usually has only one file system, but it may have more than one file system. A file system is designed in a way so that it can manage and provide space for non-volatile storage data. All file systems required a namespace that is a naming and organizational methodology. The namespace defines the naming process, length of the file name, or a subset of characters that can be used for the file name. It also defines the logical structure of files on a memory segment, such as the use of directories for organizing the specific files. Once a namespace is described, a Metadata description must be defined for that particular file. The devices are also considered to be a part of this hierarchy. To access a device we need to attach it to a folder which acts as sort of a gateway. As the image shows there is only a single root directory. All files and folders are its branches.

  • / (root filesystem): The root filesystem is the top-level directory of the filesystem. It must contain all of the files required to boot the Linux system before other filesystems are mounted. It must include all of the required executable and libraries required to boot the remaining filesystems. After the system is booted, all other filesystems are mounted on standard, well-defined mount points as sub-directories of the root filesystem.
  • /bin: Stands for “binaries” and contains certain fundamental utilities, such as ls or cp, which are generally needed by all users.
  • /dev: This directory contains the device files for every hardware device attached to the system. These are not device drivers, rather they are files that represent each device on the computer and facilitate access to those devices.
  • /etc: Contains the local system configuration files for the host computer.
  • /lib: Contains system libraries, and some critical files such as kernel modules or device drivers.
  • /sbin: The /sbin directory is similar to the /bin directory in that it contains essential programs. But it differs with the addition that it is intended to be used by the root user.
  • /boot: Contains the static bootloader and kernel executable and configuration files required to boot a Linux computer.
  • /root: This is not the root (/) filesystem. It is the home directory for the root user.
  • /home: Home directory storage for user files. Each user has a subdirectory in /home.
  • /mnt: Stands for “mount”. Contains filesystem mount points. These are used, for example, if the system uses multiple hard disks or hard disk partitions. It is also often used for remote (network) filesystems, CD-ROM/DVD drives, and so on.
  • /proc: Contains all processes marked as a file by process number or other information that is dynamic to the system
  • /sys: /sys is another virtual directory like /proc and /dev and also contains information from devices connected to your computer.
  • /tmp: A place for temporary files which should be preserved between system reboots.
  • /usr: Used for miscellaneous purposes, and can be used by many users. Includes administrative commands, shared files, library files, and others
  • /var: Typically contains variable-length files such as log and print files and any other type of file that may contain a variable amount of data
  • /srv: The /srv directory contains data for servers. If you are running a web server from your Linux box, your HTML files for your sites would go into /srv/http (or /srv/www). If you were running an FTP server, your files would go into /srv/ftp.

Types of Linux File System

When we install the Linux operating system, Linux offers many file systems such as Ext, Ext2, Ext3, Ext4, JFS, ReiserFS, XFS, btrfs, and swap.

  • Ext
  • Ext2
  • Ext3
  • Ext4
  • JFS
  • XFS
  • btrfs
  • swap

We’ll delve into each one of these Linux File Systems and give a brief description.

Ext: “ext” is an acronym that stands for “extended file system” and was created in 1992 and is the very first file system designed specifically for Linux. Its functionality was designed partly based on the UNIX file system. The purpose of its creation originally was to innovate beyond the file system used before it (the MINIX file system) and overcome its limitations.

Ext2: also referred to as “second extended system”. Created in 1993, ext2 was designed to be the successor of the original extension system for Linux. It innovated in areas such as storage capacity, and general performance. This file system notably allows for up to 2 TB of data. Like ext, this file system is very old, so it really should just be avoided.

Ext3: ext3, or third extended system, created in 2001, surpasses ext2 in that it is a journaling file system. A journaling file system is a system that records in a separate log changes and updates to files and data before such actions have been completed. This means that if for some reason, the computer or hard disk(s) crash or experience some kind of power failure, this separate log containing the changes made before the crash can be used to access that stored data, thus repairing and restoring the files upon reboot.

Ext4: ext4, standing for “fourth extended system”, was created in 2006. Because this file system overcomes numerous limitations that the third extended system had, it is both widely used, and the default file system that most Linux distros use. While it may not be the most cutting edge, it is absolutely reliable and stable — which is really valuable in Linux.

JFS: The file system JFS was created by IBM in 1990 and the name JFS is an acronym standing for Journaling File System, as we’ve already covered this concept with the number 3 file system in this article, you should already be quite familiar with what exactly this means.

XFS: xfs, an acronym that stands for “Extent File System”, was created by Silicon Graphics and originally made for their OS “IRIX”, but was later given to Linux. Created in 1990, XFS is a 64-bit high performance journaling file system. It’s particularly noteworthy for how incredibly well it works with very large files. Though contrarily, not especially the best with smaller files.

Btrfs: btrfs, which is yet another acronym standing for B Tree File System, created by Oracle in 2009. It is regarded as a rival file system to ext4, though it’s consensus that overall ext4 is the better file system, as it transfers data faster and offers more stability but although this is the case, that does not mean btrfs isn’t worth looking into.

Swap: The swap file system is used for memory paging in Linux operating systems during the system hibernation. A system that never goes in hibernate state is required to have swap space equal to its RAM size.

Linux File System Features

In Linux, the file system creates a tree structure. All the files are arranged as a tree and its branches. The topmost directory is called the root (/) directory. All other directories in Linux can be accessed from the root directory.

Some key features of Linux file system are as following:

  • Specifying paths: Linux does not use the backslash (\) to separate the components; it uses forward slash (/) as an alternative. For example, as in Windows, the data may be stored in C:\ My Documents\ Work, whereas, in Linux, it would be stored in /home/ My Document/ Work.
  • Partition, Directories, and Drives: Linux does not use drive letters to organize the drive as Windows does. In Linux, we cannot tell whether we are addressing a partition, a network device, or an “ordinary” directory and a Drive.
  • Case Sensitivity: Linux file system is case sensitive. It distinguishes between lowercase and uppercase file names. Such as, there is a difference between test.txt and Test.txt in Linux. This rule is also applied for directories and Linux commands.
  • File Extensions: In Linux, a file may have the extension ‘.txt,’ but it is not necessary that a file should have a file extension. While working with Shell, it creates some problems for the beginners to differentiate between files and directories. If we use the graphical file manager, it symbolizes the files and folders.
  • Hidden files: Linux distinguishes between standard files and hidden files, mostly the configuration files are hidden in Linux OS. Usually, we don’t need to access or read the hidden files. The hidden files in Linux are represented by a dot (.) before the file name (e.g., .ignore). To access the files, we need to change the view in the file manager or need to use a specific command in the shell.

Conclusion

In this article we have covered things like what linux file system, linux directory structure, types of linux file system and features of the linux file system. After reading this blog you will be able to understand which folder stores which file and who has permissions to change or edit files in linux.

--

--

No responses yet