Linux File Structure Explained

Linux File Structure Explained


Linux has a hierarchical file system that follows a parent-child relationship

This file system is called the Linux Filesystem Hierarchy Standard (FHS).

The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It is used by other UNIX variants as well such as Linux. It is maintained by the Linux Foundation.

In the Linux file system hierarchy, there is a single highest directory called the root directory denoted by the symbol /. All other directories and files are hierarchically children of this root directory which means all are organized under the root directory.

/ directory

In Linux, the / or root directory is the highest-level directory in the file system hierarchy. It is denoted by a forward slash /. It is the starting point for all file paths on the system and contains all other directories and files on the system. This is where everything starts from.

In the above image, I used the cd command to change my current directory to / directory and then I used ls command to show the list of directories that are inside the root.

You can see all the child directories inside the / root directory. Let's start with the /bin

bin directory

This directory contains binaries (binary files) of the programs that are installed on the current Operating system as well as core utility files required for the operating system to work properly. It also contains terminal commands such as ls, cd, mv, cp, and more.

The /bin directory is a part of the system's default search path, which means that when a user types a command in the command prompt, the system will look for the corresponding binary file in /bin (as well as other directories in the search path) and executes it if it's found.

boot directory

As its name suggests, this directory contains files that are required by the operating system to boot properly.

When the computer starts up, the BIOS or UEFI firmware initializes the hardware and looks for a bootable device. If the boot device is a hard drive, the firmware loads the bootloader from the first sector of the disk and executes it. The GRUB (Grand Unified Bootloader) on Linux systems, which loads the Linux kernel is usually located in the /boot directory. (GRUB + Boot files)

dev directory

This directory represents all the physical and virtual devices that are mounted (connected) to the system.

The device files in /dev are organized into child directories (subdirectories) based on the type of device they represent. For example:

  • /dev/block contains device files for block devices, such as hard drives and solid-state drives.

  • /dev/tty contains files for serial and parallel ports.

  • /dev/net contains the network interfaces.

etc directory

/etc contains configuration files, applications that are installed, and some system files, and as you can see most of the configuration files have that .conf extension. It also contains configuration information for the sudo command, which allows users to run commands with root privileges.

home directory

This directory is where the user's data is stored. For example, my account username is shubh, so my home directory is located at /home/shubh. This directory contains all my personal files and settings, such as documents, downloads, music, pictures, and configuration files for the applications that are installed. /home also contains all other user's data as well.

Note: home directory is denoted by a tilde sign ~

lib directory

/lib contains shared libraries that are required by the system and applications.

The /lib is usually reserved for essential system libraries, while additional libraries that are used by applications are typically located in other directories like /usr/lib or /usr/local/lib

It is like Program files in the Windows operating system.


This directory is similar to /lib but for 32-bit version files. It contains all the files that are installed for software that supports 32-bit applications.


Similar to /lib32 but for 64-bit version files. It contains all the files that are installed for software that supports 64-bit applications.

media directory

/media is used as a mount point for removable media devices, such as USB drives, external drives, CDs, and DVDs. When a removable media device is connected to the system, the device's file system is automatically mounted at a subdirectory within /media, allowing the user to access the device's files and folders.

For example, if you connect a USB drive to the system, the system will create a new subdirectory under /media, such as /media/usb and mount the file system of the USB drive at that location. However, it depends on different cases.

(Ignore my nickname) You can see my Pen drive in /media/shubh/

mnt directory

/mnt is also a directory that is commonly used as a mount point for temporarily mounting file systems or storage devices. The acronym "mnt" stands for "mount" and this directory is typically used to mount various file systems such as removable media (e.g. USB drives, CD/DVDs), network file systems, and other local file systems.

Note: Both /mnt and /media directories are used as mount points for temporarily mounting file systems or storage devices. However, there is a slight difference in their usage and conventions.

/mnt is generally used for manually mounting file systems, as well as for system administrators to temporarily mount file systems while the /media is typically used by the operating system to automatically mount removable media, such as USB drives and CDs/DVDs.

opt directory

/opt is a directory that is used for installing optional or add-on software packages that are not provided by the distribution's package manager. Here "opt" stands for "optional".

In the above image, you can see that Brave browser required some additional files to be installed which are kept in /opt/

proc directory

/proc is a directory that contains all the currently running processes. There is one important point to note is that the /proc file system is not a physical file system, but rather a virtual file system that is generated in memory and populated with system information by the kernel.

Linux kernel can send and receive information from here to the terminal.

root directory (not "/")

/root directory is not the same as / directory. The /root directory is the home directory of the system's root user. The root user is a special administrative user with full privileges to perform any action on the system.

The root user's home directory contains several subdirectories that are similar to those in a regular user's home directory, such as Desktop, Documents, Downloads, Pictures, and Videos. However, these directories are typically used for system-related files and configuration settings rather than personal files.

run directory

/run directory is a temporary filesystem that is created at boot time and is usually stored in the RAM of the System. It is used to store runtime data that is needed by the system and applications during their ongoing operations.

For example:

  • /run/lock: A directory that contains lock files for various processes.

  • /run/user: A directory that contains runtime data for individual users.

sbin directory

/sbin is similar to /bin which contains binary files, however, s in /sbin stands for "system". The programs contained in this directory are typically critical system utilities that require root access to execute and are not intended for use by regular users.

tmp directory

/tmp contains all the temporary files that are needed only for a short period of time.

These files may include log files, cache files, and other types of temporary data.

snap directory

/snap directory is used by the Snap package management system. Snap packages are self-contained software packages that contain all of the dependencies and libraries needed to run the software. /snap directory is where Snap packages are installed on the system. When a Snap package is installed, its files are placed in a directory under /snap with each package having its own unique directory.

As you can see in above image, I have installed ksnip software to take screenshots of my screen, this software has its own snap sub-directory /snap/ksnip/ that contains all of its dependencies and files. The snapd daemon manages the installation, configuration, and updation of the packages.

For example: if I want to install software which is available on the snap store then I would have to use sudo snap install package-name command to install that snap package.

usr directory

/usr directory contains all the files and directories that are shared with all the users of the system. The name /usr doesn't mean "user", it stands for "Unix System Resources" which was intended to contain user-accessible system resources.

For example:

  • /usr/sbin is for commands that can only be (or are only meaningful when) executed by the root user, like mount and fdisk

  • /usr/lib: Contains libraries for programs stored in /usr/bin and /usr/sbin.

Note: I don't wanna go too deep into this as it may get overwhelming.

var directory

/var directory is used to store variable data files that are generated and updated during the operation of the system. This directory contains files such as backups, crash logs, metrics, some other log files, and some other temporary variable files as well.

Here "var" stands for "variable", and these containing files are expected to grow over time, such as log files, spool files, and temporary files.

swapfile (not a directory)

/swapfile is used as a swap space for virtual memory management.

Virtual memory is a technique used by operating systems to create some extra virtual space in case your RAM gets completely used.

When the physical memory (RAM) of a system is full, the operating system moves some of the less-used data from RAM to the swap space on the disk.

The /swapfile is typically created during the installation of a Linux system or can be created manually.

The size of the /swapfile can be adjusted depending on the needs of the system. It can also be disabled or deleted if not needed, although having some swap space is usually recommended.


With that said I have covered all the files of the Linux File structure.

I hope this article was helpful.

Did you find this article valuable?

Support Shubh Sharma by becoming a sponsor. Any amount is appreciated!