linux file system

Explained Linux file system and Directory structure

Overview

A file system is a way In which the operating system’s files are organised, stored, retrieved and updated on a system’s hard disk partition. Here In this guide, I’ll explain the Linux file system and why It is imperative to understand them.

Linux file system is completely different from the windows file system as windows uses Disk Operating System and Linux uses the file system hierarchy standard.

Why it’s important to understand the Linux file system?

Well, For example, you may need to edit the grub configuration file when you are installing two operating systems in a computer. Or suppose you need to edit the configuration of an application. Or you need to manually edit system configuration files for permissions or users etc.

That’s why It’s important to understand the file system and the directory structure.

Well, all that said, let’s see the types of Linux file system and how the directories are organised.

Types of Linux file system

Linux has various type of file systems. We’ll discuss each of them here.

Ext: Extended file system abbreviated as ext first implemented in 1992 as the first and primary file system for Linux kernel. EXT can handle 2GB of data and Remy card designed this to overcome the limitations of traditional MINIX file system.

Ext2: Second extended file system designed by Remy Card to overcome certain limitations of Ext file system. Ext file partition had many limitations such as data manipulation, Inode modification and support for timestamp for file accessstoredes.

Ext2 designed and implemented as a default file system for most of the distributions available at that time. Solid state devices and pen drives are still using this file system to run the hardware.

Ext3: Third extended file system also known as Ext3 merged with Linux kernel on November 2001. Journaling system introduced in EXT3 which gives a more reliable solution that there were no need to check the file system after a shutdown.

Ext4: Successor to Ext3 and also known as the fourth extended file system is one of the most used file systems to date.

Ext4 was designed to overcome the stability, performance and storage issues that Ext3 had. It was incorporated to the Linux kernel on 2006.

Ext4 can support files from 1 exbibyte (EiB) and single files with sizes up to 16 tebibytes (TiB).

JFS: Journaled file system was developed by IBM for AIX UNIX as an alternative to system extended file systems. JFS is much handier when there is a limited CPU power.

Btrfs: Is an abbreviation for B-tree file system. It was developed by Oracle on the basis of copywriting principle to use with Linux kernel. Btrfs is introduced in 2007 and in 2013 It has been declared as a stable file system for Linux. However, It’s still under development and intended for production uses.

Linux Directory structure

Linux uses a hierarchical file system structure in which everything considered as a file. Let’s look at how the files are organised in a Linux file system.

Quick disclaimer: These are the directories which power your Linux operating system. So don’t make any unnecessary changes until you know what you are doing.

All of the below operations require you to have a basic understanding of the Linux terminal. If not make you sure you check out this article and come back here. Read now: 20+ Most useful Linux terminal commands | CodeHacks

Unlike Windows or other operating-systems, Here in Linux root(/) is the base and all other files are the children. Let’s discuss each of them in detail.

linux file system

1. /bin: This is the directory where all binary executable program files reside. These are the commands which are available to all the users. Commands like cd, mv, nano etc are loading from here.

bin in linux file system

2. /dev: This directory contains device files.Files get stored here when the system boots. These are the files related to webcam and other plugged in devices such as pen drives.

dev in linux file system

3. /boot: Here you’ll see files which are required to boot into your systems such as grub and EFI. Don’t mess with these files until you really need to edit something. Because a simple mistake here can make your system not to boot.

4. /etc: Contains system-wide configuration files. Here you’ll find configuration files of most of the applications and user configuration files. For example, Linux stores the password of each user in this directory.

linux file system etc

5. /lib: This is where code libraries stored. Binary and system binary executable files use these libraries to load the snippets of codes to perform various tasks. And in some distros, you can find kernel-related files that are used by binary files. Apart from /lib we may have lib32 and lib64 to store libraries for 32bit and 64-bit applications respectively.

6. /mnt & /media: These folders are used to store information about external storage devices that are attached to the system. Whereas /mnt is used by users to manually mount the devices and /media to load the devices automatically.

7. /proc: This directory contains information about running processes. Also, users can see the CPU and kernel information from this directory. Linux file system assigns each task a number. So here you’ll be able to find the status of each running applications.

proc in linux file system

8. /tmp: This is a volatile directory. Applications use this directory to store the temporary files until system reboots. If any application crashes you can recover the files from here.

9. /usr: Earlier Linux used this directory to store the user files. Now each user has a separate directory in /home folder. Here you’ll find applications, documentations, libraries and many more. Apart from Ubuntu, Debian, Mint most of the other Linux distributions use this directory to store the binary files.

Also here you’ll find sub-directories, like /usr/bin, /usr/sbin, /usr/src used to store the binary commands used by applications. So in most of the time installed applications execute binary commands from this directory.

10. /sbin: Contains system administrator commands. There are some binary files which are hidden from normal users. These commands are available to root users. System binary executable commands are loading from here. Commands such as ifconfig, fdisk can be accessed from here.

sbin linux file system

11. /var: var directory contains folders and files which are supposed to change in size. This directory stores the subdirectory such as /var/log to store log data, /var/crash to store crash reports, /var/www to store web files etc.

Linux named this directory as var because the files and folders will likely to change in size.

But these days there are many other directories which may also change in sizes such as /dev and other virtual directories.

12. /srv: You may don’t find this directory until you are installed any server related files in your system.

13. /sys: Is also another virtual directory which contains information about connected devices. Unlike /dev and /proc this directory also contains kernel-related files.

14. /snap: This is where the application files reside those are installed by snapcraft package manager.

Conclusion

There are plenty of Linux distributions available to use. However, most of them will be following the same file system hierarchy. Understanding the Linux file system will give you complete control over the system and much useful if you are into Linux operating system development.

Leave a Comment

Your email address will not be published. Required fields are marked *