Linux Filesystem Hierarchy Explained!

Working with Linux becomes much easier if you know the purpose of different directories present inside the root directory.

In this article, we will try to understand the use of each and every directory present inside the root in brief.

Let's get started with the most common statement you must have heard before.

Everything is a file in Linux

Let's have a look at the directories I am talking about. Navigate to the root directory, and there you will find all directories.

$ cd /
$ ls

And here you can see so many directories

bin   dev  home  lib64  mnt  proc  run   snap  srv  tmp  var
boot  etc  lib   media  opt  root  sbin  src   sys  usr

Initially, it seems to be confusing and hard to navigate around all of these directories in order to find what specific purpose these directories serve, let's try to answer that question.

/home - This directory serves as the home directory for all users except the root user.

/opt - This directory is used for optional packages, if you want to install additional packages on your system this would be an ideal location for storing those additional packages.

/mnt - If you want to mount any network shared drive on your system then this directory is the right place to do that.

/tmp - This directory is used to store temporary files which will be deleted upon system shutdown.

/media - All of your external media devices can be found mounted under this location.

/dev - This directory contains files for all of your devices such as external hard drives, printers, mouse, etc.

/bin - This directory contains all the basic programs that you have been using so far while working with a shell such cd, pwd, mkdir, etc.

/etc - This directory is used to store configuration files in Linux, you can find system-wide configuration files for different services here.

/lib - This is the place where you will find all shared libraries that are required by different programs.

/usr - This is the directory where all non-essential user applications, directories, files, and libraries can be found.

/var - This directory stores all variable data which changes as the system is used such as logs, cache, backups, etc. For eg: auth.log

/srv - This directory contains data for services provides by the system.

/proc - The proc filesystem tells you information about the system, state of Kernel, memory, processes, and a lot more.

/boot - This directory contains files that are used by the system to boot.

This is a brief overview of the Linux Filesystem and I hope you found it helpful.

You can find more details about filesystem hierarchy in the Linux manual using the command written below.

$ man hier