Understanding the CentOS 7 filesystem hierarchy

May 15, 2021

We can compare a filesystem to a refrigerator, or any other storage with multiple shelves that is used for storing different items. These shelves or compartments help us to organize grocery items in our refrigerator by certain characteristics, such as shape, size, type, and so on. The same analogy is applicable to a filesystem, which is the epitome of storing and organizing collections of data and files in human-usable form.

A filesystem is organized in an inverted root tree design with / (a forward slash; pronounced root) as the root of the filesystem, and underneath /, we see the rest of the directories and subdirectories, as shown in the following diagram:

filesystem hierarchy

Important filesystem directories in CentOS 

This layout of the filesystem hierarchy is described in the Linux Filesystem Hierarchy Standard.

Here, / represents two things:

  • The root directory at the top of the filesystem hierarchy.
  • It is also used as a directory separator to separate one directory from another. For example, the home directory is inside the / directory; hence, it is referred to as /home/. Similarly, if we have another directory, alice, above the /home directory, it is represented as /home/alice/.

Each directory is used for the standard purpose of organizing files of a particular type and purpose. Any directory can contain four types of content, asshown in the following table:

Content type

Description

Static

This type of content remains unmodified until explicitly edited

Dynamic or variable

Thistype ofcontent generally gets modifiedcontinuously

Persistent

This type of content retains changes made even after reboot, for example, configuration files

Runtime

This type of content mostly resides in memory and its contents are cleared on reboot, for example, files used by processes of the system

The following table lists thelocationand purpose of important directories in CentOS:

Location

Purpose

/boot

Contains files required to start the boot process of CentOS 7, including the GRUB configuration file, the kernel image (vmlinuz), the RAM disk file (initramfs), and so on.

/dev

Contains special device files used by the system to access hardware and software devices such as /dev/sda (for the hard disk drive), or /dev/pts1 (for representing a psuedo Terminal).

/etc

Contains configuration files for applications (resolv.conf, passwd, and so on) installed on this particular system for system-wide changes.

/root

The home directory of the root user, also known as superuser.

/home

Contains home directories of normal users for storing their personal files.

/run

Contains runtime data, variables, process IDs, lock files, and so on for processes started since the last boot. The contents of this directory are regenerated upon restarting the system (in CentOS 6, its contents were stored in /var/run and /var/lock). One of the important subdirectories in this directory is as follows:

  • /run/media: Used as a mount point for removable devices such as USB, CDs, DVDs, and so on

/var

Contains the variable data, specific to the system that persists across reboots. The content and size of these files change dynamically (for example log files, printer-spooled documents, website content, and FTP content) as the system is running.

The /var directory can be put in its own filesystem so that the growth of files does not fatally affect the system.

/tmp

Contains temporary files; has write permissions enabled for all users on the system. The files that have not been accessed, modified, or changed in last 10 days are deleted automatically from this directory. Another temporary storage directory in our system is /var/tmp.

/usr

Contains application files, shared libraries, and documentation. The files in this directory are static, read-only, and shareable. It also has three important sub-directories, as follows:

  • /usr/bin: Contains essential user commands (ps, ls, cp, and so on)
  • /usr/sbin: Contains system administration commands (fsck, shutdown, and so on)
  • /usr/local: Contains data and program specific to the local machine
  • /usr/include: Contains header files used to compile applications

/bin

A symbolic link to /usr/bin.

/sbin

A symbolic link to /usr/sbin.

/lib

A symbolic link to /usr/lib; contains shared libraries used by applications stored in bin and /sbin.

/lib64

A symbolic link to /usr/lib64 and contains the 64-bit shared libraries used by applications stored in /bin and /sbin.

/mnt

This directory is used as temporary mount point for partitions and devices in the filesystem tree, such as for the mounting of NFS filesystems.

/proc

 

Contains thevirtual filesystem(as in, it existsonlyin memory);also known as a psuedo-filesystemof the kernel. It contains dynamic runtime system information (for example, system memory, devices mounted, hardware configuration, and so on) and is considered the control and information center of the kernel. Some utilities directly call the files stored in this directory and display the information such as free memory using the /proc/meminfo file and arp table info using the /proc/net/arp file, and so on.

Related Articles

How to Install MongoDB on CentOS 8 Linux

How to Install MongoDB on CentOS 8 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

read more
How to Install OpenCV on CentOS 8 Linux

How to Install OpenCV on CentOS 8 Linux

OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in commercial...

read more

Lorem ipsum dolor sit amet consectetur

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

12 − eight =