Linux Filesystem Hierarchy

Linux Filesystem Hierarchy

by Elena Mofar, Published on May 23, 2023

Everything in Linux is a file.


So, bago tayo mag-start sa kahit na ano pa man, we need to familiarize ourself with how Linux handles their directories.


Ano yung mga default directories, and kung ano yung purpose of each.


Linux uses a hierarchical directory structure kung saan ang mga directories natin may contain both files and another directory (also called as a sub-directdory).


Yung main directory natin is called a parent directory, and yung sub-directory na nasa loob ng parent directory na yan is called a child directory.


So, For example, we have a directory Folder1 , and inside we have 2 Directories Dir1 and Dir2 :

Parent and Child Directory Illustration

If another directory exists inside Dir1, say Dir3 – then, Dir1 would be the parent directory of Dir3 and Dir3 would be its child Directory :

Parent and Child Directory Illustration

In Linux, all sub-directories are under its parent directory – the root directory, denoted by “/”.


The Root directory (/) is not a child of any directory, therefore, it is the topmost Directory in the Linux Directory Structure.


After installation, Linux creates default directories that are all located inside the Root Directory (/).


These default directories can be seen here:

We need to familiarize ourselves with the uses and functions of some of the most commonly used sub-directories.


These are the commonly used root sub-directories

/etc ( slash et-cee directory)


This sub-directory holds system configuration files.


As we further along with server and system configurations, we will be using and editing files located here.


/boot


Contains all files needed to boot your Linux machine


These includes the kernel, bootloader, and boot configuration files.


/home


This is where the home directories of users residing in our system are stored.


The home directory name of a user is equal to its username.


So, if we have a user with username john123, its home directory would be : /home/john123


/root (slash root directory)


The root user is the administrator user account for the entire Linux system.


It also has its own home directory separate from the home directories of our regular users.


The home directory of the root user resides in the /root directory.


/var (variable directory)


This directory contains variable data that changes while our Linux system is up and running.


This includes log files, spool, status and other variable dynamic data.


Also, when we are already in server configurations – you will see that servers like an HTTP server, FTP and Mail servers store their files inside the /var directory.