Magazine

Understanding the CentOS 7 Filesystem Hierarchy

Posted on the 15 May 2021 by Satish Kumar @satish_kumar86

We can compare a filesystem to a refrigerator, or anyotherstorage with multipleshelvesthat 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 homedirectory is inside the /directory; hence, it is referred to as /home/. Similarly, if we have another directory, alice, above the /homedirectory, 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/runand/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/vardirectory 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 inbinand/sbin.

/lib64

A symbolic link to /usr/lib64and contains the 64-bit shared libraries used by applications stored in/binand/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 freememory using the /proc/meminfofile and arp table info using the/proc/net/arpfile, and so on.


Back to Featured Articles on Logo Paperblog