Linux-File System

Linux-File System

·

4 min read

Linux file system has a hierarchical tree structure. Unlike OS like Windows(which has multiple root folders), Linux has only one root folder.

In Linux, we have one root folder just like the root of a tree then inside the root folder there are a couple of different folders, each having its own purpose and further the folders can have different folders and files inside them.

Some of the folders that reside inside the root folder are:

  • /home: Every Linux user gets their own space inside the home directory. It contains home directories of all non-root users.

  • /bin: bin stands for binaries. All the basic commands that we use on Linux have separate binary files and all those files are located inside /bin folder.

  • /sbin: sbin stands for system binaries. Like /bin folder this folder also contains the binary files but the difference is that the commands in this folder are system-relevant. These commands need a super user's permission to execute them. It contains commands like adduser( to add user), chpasswd( to change password ) etc.

  • /lib: lib stands for library. It holds the libraries for those binary files or the commands.

  • /usr: usr stands for user. It is located just before the home directory for different users.

💡
/usr folder also contains the folders like /bin, /sbin, /lib. Now the question is why? The reason behind this is historic. Because of the storage limitations, it was split into a root binary folder and a user binary folder.
💡
We have to be aware of the thing that when we execute commands like ls, in the terminal they are usually executed from the user/bin folder. In some OS, the root/bin folder may contain fewer commands than the usr/bin folder.
💡
In /usr folder, there is another folder called /local. This /local folder also contains /bin, /lib, /sbin folders and the difference is that this is a location, where the application that we as Linux users install ourselves resides. For example, third-party applications like Java, python, docker etc. Application installation will be split into these folders. For example, if you are installing Java, then the binary files of Java are stored in the /bin folder and libraries are stored in the /lib folder and so on. One thing to be noted is that the applications installed in this folder will be available for all the users on the computer.
  • /opt: It is another folder where the third-party applications/programs that we install reside. The difference between usr/local and /opt is that there are some applications that we want to install that cannot be splitted and stored in different directories such applications reside in /opt folder.

  • /boot: It is basically for booting the system. It contains the files required for booting. This is a folder in which we as users do nothing.

All the folders up to now are READ ONLY FOLDERS!

  • /etc: It is a location in the root where system configuration is stored, this could be network interface configuration, or Linux user's data password meaning things that are not only readable but also writeable.

  • /dev: dev stands for devices. It is the location of device files like webcam, keyboard, hard drive etc. App and Drivers will access this folder, not the users. It contains the files that the system needs to interact with the device.

  • /var: var stands for variable. When the OS starts, it logs some data and these logs are stored in a folder called /var inside /log folder. Generally, this folder stores the logs from different operations that are running on the computer.

  • /tmp: tmp stands for temporary. It stores temporary resources required for some processes kept here temporarily.

  • /media: This folder contains subdirectories, where removable media devices inserted into the computer are mounted. For example, when you insert a CD. A directory will automatically be created and you can access the contents of the CD inside the directory.

  • /mnt: This folder is used to store temporary resources while mounting manually. For example, we can mount a file system to the OS manually.

💡
Usually, we are not the ones interacting with these folders. The installer/Package Manager is handling this, and the operating system is handling this.

Hidden files:

Hidden files are primarily used to prevent important data from being accidentally deleted. They are automatically generated by programs or operating systems. The name of these files starts with a dot and that's why in UNIX they are also called "dot files". We can also create hidden files or folders by starting it's name with a dot.

Â