Linux File System

Vinayak Kokane
7 min readNov 17, 2020

Learn all about Linux File System

Hi everyone there, hope you are in fresh and good mood while reading this blog! In this blog, we are going to discuss about File System of your Linux operating system. If you want to get a command over functionalities of any OS, it is essential to have a clear understanding of its File System. So let’s first understand what is generally a file system is?

What is a File System?

Ancient File System

Basically, File system can be thought as a logical component which manages how and where the data gets stored over disk or partitions, typically Hard Disk Drive (HDD). It usually contains different group of folders called directories, which can further contain other files and folders.

Note: Without file system, all files would have no organization and it would be impossible for a file with the same name to exist.

So, we have understood what is file system in general. Now, let’s move on to our topic i.e. Linux File System.

What is a Linux File System?

Every data in Linux OS is handled through files and the whole storing, managing and retrieving of these all files is done by Linux file system. Like any other file system, all directories together build a Linux File System.

Linux File System is organized as a hierarchical structure similar to an inverted tree. Linux file structure files are grouped according to purpose. Ex: commands, data files, documentation. This structure follows a standard layout recommended by Filesystem Hierarchy Standard (FHS), which is a standard maintained by the Linux Foundation.

Below is the picture of tree-like structure from root directories to all sub-directories.

Tree like view of Linux File System

Unlike Windows which has multiple roots, the Linux only allows one root. You can see a picture of standard folders on the root directory. The root directory is where all other directories and files on the system reside and is designated by a forward slash /.

Now in the below picture, we have shown you a different directories of Linux File System.

So let’s start to explore and discuss why, what and how about each of all directories!😃

/bin directory

bin being short for binary. These are the most basic binaries which is another word for programs or applications. Things like ls to list out files in your directory or cat to display output of file on command-line and other basic functions are stored here.

/sbin directory

These are system binaries that a system administrator would use and user wouldn’t have access to it without permission. These binary executable files are reserved for programs essential for booting, restoring and recovering.

/boot directory

This is a directory where you shouldn’t play in. Jokes apart! It contains everything that your OS needs to boot in other words boot loaders live here. Kernel executable files are stored here.

/dev directory

Now this is a directory where your devices live. Linux follows “Everything is a file” principle, means your hardware devices are also files like printer, keyboard, mouse…everything! And this dev directory is an area where you will find everything else here from your webcam to keyboard.

This is typically a directory that drivers and applications access, so you will rarely play within this area.

/etc directory

The name of this folder has been argued as edit to configure (etc) but the co-founder of Linux, Dennis Ritchie (And you might know, Linus Torvalds , founder of Linux) confirmed that it indeed mean etcetra (etc) .

This is where all your system-wide configurations are stored. So, if you have a system-wide application on your Linux, you can find its configuration files here.

In the picture, all blue colored names shows us that they are configuration folders.

/home directory

In this folder, your personal files and documents reside. Linux is a multi-user environment so each user is assigned a specific directory that is accessible only to them and the system administrator.

The home directory contains your personal configuration files, the so-called leading dot files. These files are usually hidden, and you need ls with -a option to view them. This directly can grow very large as you store your files, downloads, applications, videos, pictures and sounds.

/lib directory

Next are the lib folders includes lib, lib32, lib64 where libraries are stored. These library files are programs that are shared among other binary applications. Binary files inside bin and sbin use these library files extensively.

/media directory

This is where your OS automatically mount your external removable devices such USB drive.

/mnt directory

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.

/media and /mnt are basically the same. However, it is recommended to use /mnt for manual mounting and leave media directory for the OS.

/opt directory

Stands for optional. This directory is reserved for all the software and add-on packages that are not part of the default installation.

Here I have installed VBoxGuestAdditions manually which shows up here in the below picture.

/proc directory

Stands for process. It is an area where you will find pseudo files that contain info about system processes and resources.

It contains runtime system info like: system memory, devices mounted, hardware configuration, etc.

/root directory

This is a directory for superuser (i.e. administrator). You can look at it as a root user’s home directory. It is only accessible to superuser. On my computer, it is an empty folder. However, it is reserved for configuration files for the root account.

/run directory

Modern Linux distributions have included this directory as a temporary filesystem (tmpfs) which stores RAM runtime data. Everything in it will be gone if you reboot or shut down your system.

/snap directory

This is a folder where snap packages are stored and are mainly used by ubuntu. Snap packages are self-contained packages that don’t depend on any other packages, dependencies, or libraries.

/srv directory

This is a service directory where service data is stored. It holds site specific data to be served by the system for protocols such as, ftp, rsync, www, cvs etc.

/sys directory

This is where you can interact with the kernel. In other words, you can consider it as an interface to the kernel. This directory is not physically written to the disk, it is created every time the system boots up. So nothing you can store here and nothing gets installed here.

/tmp directory

This is where applications store the temporary files they need during a session. For example, when you are writing a word document in a word processor, it stores a temporary file saving all you write. If for some reason your system crashes before saving the file, the word processor can search this directory to find a recent saved copy to recover your text. This directory is usually empty when you reboot your system.

/usr directory

usr stands for Unix System Resources. It belongs to the user applications as opposed to /bin or /sbin directories which belong to system applications. Any application installed here is considered nonessential for basic system operation. This directory is read-only and applications should not write anything into it.

/usr subdirectories:

  • /usr/bin contains the vast majority of binaries on your system. Binaries in this directory have a wide range of applications. For example, vi, firefox, atom, … are all here.
  • /usr/sbin contains programs for administrative tasks. They need privileged access. Similar to /sbin, they are not part of $PATH.
  • /usr/lib contains program libraries. Libraries are collections of frequently used program routines.
  • /usr/local contains self-compiled or third-party programs.

/var directory

Stands for variables. This directory contains variable data like system logging files, mail and printer spool directories, and transient and temporary files. Among the various sub-directories within /var are /var/cache (contains cached data from application programs), /var/games(contains variable data relating to games in /usr), /var/lib (contains dynamic data libraries and files), /var/lock (contains lock files created by programs to indicate that they are using a particular file or device), /var/log (contains log files), /var/run (contains PIDs and other system information that is valid until the system is booted again) and /var/spool (contains mail, news and printer queues.

/cdrom directory

This is a legacy directory to mount CD-ROM. However, today CD-ROMs are automatically mounted on media directory.

Now here we end our discussion of Linux File System, We hope this blog has clarified your concepts and made them stronger!

If you have found this blog useful, share it with your peers, applaud it and drop your thoughts and suggestions in comment box.

Thank You So Much!

--

--