File Management

Linux File System Hierarchy

Linux File System Hierarchy

Maybe you have just installed Linux, and now you want to know about the hierarchy and structure of the Linux File system. You may also wonder why different types of software are installed in its different directories.

To know the Linux Filesystem's structure, let's begin with the entry or starting point of the directories, which is known as the root directory. In this post, we will use the tree command to view the hierarchical structure of directories in the form of the tree in the terminal.

Let's install a tool named “tree” to view the structure of directories and better understand the hierarchy.

To install the “tree” on Ubuntu or Debian based systems, use the command below:

$ sudo apt install tree

To install the “tree” on Fedora or RedHat, use the appended command:

$ sudo dnf install tree

Once “tree” is installed, first, change the directory to the root directory(/), using the “cd” command:

$ cd /

Then run the tree command here:

$ tree

It has shown all the directories and subdirectories, which was actually not needed since we only wanted to see the directories of the current folder.

So, let's modify the tree command a little bit according to our needs, and try this command instead:

$ tree -L 1

In this command, the “-L” is representing the level we want to see, and the “1” is representing the level number.

Now, we have a better view of the directories of our interest in the root directory.

Next, let's learn about each directory.

Directories:

Let's begin the root directory “/”:

/

This is the entry point of all directories and is described as a forward slash, which is actually the home of the Operating System. Everything is in it. Not every user has read and write privileges to this directory; only the administrators or allowed users of the operating systems can have access to such privileges.

/bin

This is the directory that has all the binary files of some important programs on the operating system. This directory holds the data about the most used commands related to making(mkdir), moving(mv), copying(cp), listing(ls), and removing(rm) a directory or file. According to the Linux Filesystem Standards, this directory cannot have subdirectories.

/boot

This is the directory that handles the ignition of the Linux Operating System. First of all, you don't need to modify anything in this directory, otherwise, you can't alter anything in it unless you have administrator's rights. You should stay away from doing anything in this directory, or else it will be a huge mess to set it up again.

/dev

This directory holds the files of the devices like a USB Device or a Hard Drive. Most of the files are either created on the boot time or when a device is attached.

/etc

This may seem a little bit funny to you, but this directory is for those types of configuration files and folders in which the system does not know where to put them. So, it is an “et Cetra” directory for the Linux Operating system.

This directory mostly contains the static program local files that affect all users. Since this directory mostly contains files related to the configuration, it is better to call it “Everything to Configure”.

/home

This is the directory where most of the user's personal data is placed. A user spends most of his time here because Downloads, Documents, Desktop, and all other basic required and much-known directories are in this “/home” directory. All the dot configuration files of a user are also in here.

/lib

These are the folders where libraries are stored. Libraries are some files that are needed by any application to perform several tasks or functions. For example, these libraries may be needed by the binary files in the /bin directory.

/media

This is the directory where all the external connected storage devices are mounted automatically. We do not need to do anything in this directory because it is managed by the Operating System itself, but if we want to mount storage devices manually, we have the /mnt directory for that purpose.

/mnt

This is the directory where you can find the other mounted drives. For example, a USB drive, an External Hard Drive, or a Floppy Disk Drive. This is not used nowadays because the devices are automatically mounted to the /media directory, but this is where we can mount our storage devices manually.

/opt

This is the optional folder. It is the directory where manually installed software by vendors is placed.

/proc

This is the directory with the pseudo files. The pseudo files contain information about the processes.

/root

Just like /home directory, /root is the house of the Administrator a.k.a. superuser. Since this is the superuser's directory, it is better not to touch it unless you have complete knowledge of what you are doing.

/run

This directory is used to store temporary data of processes running on the Operating System.

/sbin

This directory is just like the /bin directory, but this is used by the superuser, and that's why “s” is used before bin.

/snap

The is the directory with the snap packages stored in it.

/srv

This directory stores the data of the services running on the system. For example, it holds the data if a server is running on the Operating System.

/sys

This directory is always created during boot time, so it is a virtual directory like /dev, and it is the directory when you want to communicate to the Kernal. It also holds information related to the connected devices.

/tmp

This is a temporary directory and holds the temporary files of the applications running on the system.

/usr

This directory contains the applications installed and used by the user. It is also known as the “UNIX System Resources”. It also has its own /bin, /sbin, and /lib directory, which is different from the superuser's /bin, /sbin, and /lib directories.

/var

This is a variable directory that contains the files and folders whose size is expected to increase with the passage of time and the system's usage.

Summary:

If you have been confused about the Linux directories and their purposes, then this post must have been a great help to you. It contains a profound and on point explanation of the topic, including the purpose of every single directory that exists in any kind of Linux based Operating System.

Linux için En İyi Oyun Konsolu Emülatörleri
Bu makale, Linux için kullanılabilen popüler oyun konsolu öykünme yazılımını listeleyecektir. Öykünme, oyun konsollarının, komut setlerinin ve ilgili ...
Best Linux Distros for Gaming in 2021
The Linux operating system has come a long way from its original, simple, server-based look. This OS has immensely improved in recent years and has no...
Linux'ta oyun oturumunuzu nasıl yakalar ve yayınlarsınız?
Geçmişte oyun oynamak sadece bir hobi olarak görülüyordu, ancak zamanla oyun endüstrisi teknoloji ve oyuncu sayısı açısından büyük bir büyüme gördü. Ç...