Skip to main content

Command Palette

Search for a command to run...

Linux File System

Let's see how data is organized, store and access efficiently inside Linux file system.

Updated
8 min read
Linux File System

What is File System and Why it's needed.

Problem Statements:-

  • So, what's the problem statement? Why do we need a file system? Once we understand the problem, we can understand what a file system is and learn more about the Linux file system.

  • So, what's the problem here? Imagine we have a lot of data. We need to perform operations on that data, such as inserts, updates, deletes, and other actions. Now, imagine we have thousands of data items. If we want to insert, update, or perform any other operation on a specific file, we first need to find that file.

  • You can see how significant the overhead becomes because the data is stored unstructured. There's no format, it's just meaningless raw data. There are no tags or identifiers to tell what the data is about.

  • So, you can understand how big the problem was there was no structured way to manage the data.

  • To solve this problem, file systems were introduced. Now, let's learn a little about file systems.

About File System :-

Now you have a basic understanding what is the problem statement there , so now time to discuss about how they solve this problem with the help of file system.

  • So, the file system is part of the operating system, as you probably already know.

  • How does the file system solve this problem? Basically, it stores all data in a structured manner. It organizes and manages data on storage devices like SSDs, hard disks, and USB drives.

  • It stores data by type so there are no problems during retrieval or operation.

  • So, this is a basic overview of what a file system is. Now, it remains to see how it stores data efficiently and what types of file systems exist. Let's explore this in the next step.

Type of File System :-

  • Before moving on to the next part, one more thing: there are many types of file systems. For example:-
  1. File Allocation Table ( FAT ) .

  2. New Technology File System (NTFS), used by modern Windows.

  3. Extended File System ( ext ), used by Linux and Unix, and we'll study this later.

  4. Hierarchical File System (HFS), used by macOS.

About Linux File System :-

  • Here also, the main idea is to store data in a structured way. The only difference is how the data is stored and how it is accessed.

  • The basic point is that the data is stored in the Linux machine itself, but what it does , they store the data in a hierarchical directory structure. This directory structure starts from the root directory, which is represented by /.

  • All files and data are found inside this root directory. This means the entire Linux file system originates from the root directory.

  • In Windows, you may have seen that a file path usually starts from a drive, like the C drive or D drive. But in Linux, it doesn't work like that. The file system starts from a single endpoint, and then deeper directories are created inside it.

  • All of your file system originates from the root directory. Now, after this, we need to look at all the directories inside the root and understand their special purpose.

Basic Command you know must :-

Now we are covered basic part about Linux file system ,so now let's understand it more in-depth. But before going to learn further more my suggestion to you learn first basic terminal command example how to create new file through terminal , folder and read a file and change directory , because in the next section we see how file system work internally , that why you need to understand these command so below is a commands read it properly and then implement according to that .

  • touch :- when we want a new file then we use touch command in terminal , means touch command is used to create a new file , so the question arise how to use this command, the simple answer is write a command name and after that you file name , then you will see new file created . For Example :- touch file.txt.

  • cd :- cd command is used to when we want to change our current directory, move from one folder to another folder . there are two use cases of this command, one is open that folder or come back from that folder, so how to that that , so basically when we are open that folder write cd and followed by folder path, means folder name , then your current directory change and that folder open , now you want to come back from that folder so basically then you write command cd .. then you will see directory change.

  • ls :- This is command is used to chech how many files and folder in current directory.

  • mkdir :- This commandis used to create a new folder , very simple to use , command name mkdir, and followed by folder name For Example :- mkdir folder_name.

  • pwd:- When you have no idea where you are , means you current folder where you are , this command show you current path folder.

  • cat :- When you have a file and want to see what's content inside file then you will use this command , they showing you content inside that file. For example cat file_name .

  • rmdir:- when we need to delete specific folder, then we are use these command . For example :- rmdir folder_name .

Create File & Case Sensitive in Linux .

First, let's look at a very basic way to create a file. To create a file, we can use the touch command, which we saw earlier. Similarly, we can create a folder using the mkdir command.

  • But in this section, my main goal isn't to teach you how to create a file or folder. My main goal is to explain case sensitivity.

  • In Linux, file and folder names are case sensitive. This means that if a file's name is in lowercase, it's considered different. And if there's another file with the same name but in uppercase, it's also considered different.

  • So, even if the names look the same, one is in lowercase and the other is in uppercase, they're considered different. The same rule applies to folders.

  • I told you this because this isn't the case in Windows. Windows is case insensitive.

I hope you understand now.

Linux File Hierarchy Structure .

In a hierarchical Linux file structure, you have a root directory, which is represented by /. From here, the entire Linux file system originates.

  • Inside the root directory, you will find all the directories that are used in Linux. This means the root directory stores everything.

  • Below is the image, then you will understand what I want to say. After that, we will discuss some of the most important directories inside the root.

Root Directory ( / ) .

We have talked a lot about the root level directory, which is represented by a forward slash /. The file system starts from here because all the remaining data is stored inside it in directories.

  • It is the base point of the entire file system, and no directory exists above it. This means every single file and directory starts from the root directory.

  • All paths in Linux begin from this root, either directly or indirectly. It acts as the top-most level in the hierarchy, and everything is organized under it.

  • No matter how deep a file is stored, it will always trace back to the root directory. This is why it is considered the starting point of the Linux file system.

Check you File system in Linux .

As we have seen, there are many types of file systems, and every file system has its own specialty. Now, if you want to check which file system your system is using, there are one commands available. You can use any one of them to check it.

One last think to add these command show you file type system they use but also show more details about that particular file it space , how much memory they used , available space , total uses and many more , you can see it in image.

Below, you can see those commands and the output they produce.

💡
So with my above explanation i hope you understand what i learn and what's my thought process on Linux File System.