This is a short explanation of the Linux file system Hierarchy. In a Linux system, all files are stored on file systems. A file-system hierarchy is the organization of these files into a single inverted tree of directories. The tree of directories is said to be inverted since its root at the top of the hierarchy, and the branches of directories and sub-directories stretch below the root.

The below diagram is a Red Hat Enterprise Linux(RHEL) 8 file-system directories.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/linux-file-system-hierarchy-1-1024×339.png" data-ez ezimgfmt="rs rscb4 src ng ngcb4 srcset" src="data:image/svg xml,”>

As seen in the diagram, the / is the root directory at the top of the file system tree. All other directories are separated by the / character. So var is a subdirectory of the root directory (/). How then can we describe the file-system directory contents?.

Linux File System Hierarchy Content types

These are the major types of content stored in a Linux filesystem.

  1. Persistent – These are the contents which should be persistent after a reboot, e.g system and applications configuration settings.
  2. Runtime – Content generated by a running process; usually deleted by a reboot
  3. Variable / Dynamic – These content may be appended or modified by processes running in the Linux system.
  4. Static content – This remains unchanged until explicitly edited or reconfigured.

Important Linux Directories – May vary from one distro to another

These are the standard Linux directories – This is pulled from a RHEL 8 server.

System Directory Purpose
/etc Contains configuration files used by system services
/root This is a home directory for the Linux superuser account, root
/boot Contains all the files needed to start the boot process.
/home This is where standard users store their personal configurations and data such as Documents, Videos, Music e.t.c.
/var Has variable data that is required to persist between boots – databases, log files, mails, cache directories, Web data e.t.c.
/tmp Stores temporary files. All Linux users can write to this directory. Files older than 10 days are deleted automatically.
/usr This directory contains shared libraries, installed software, and read-only program data.

Some of the important subdirectories include:

/usr/bin: Mostly user commands are located here.

/usr/sbin: Hosts System administrative commands that required privilege escalation to run.

/usr/local: For locally customized software.

/dev This contains special device files used by the system to access hardware.
/run The processes started since the last boot stores their runtime data here, e.g. process ID files and lock files. These contents are recreated on reboot.

Other directories that may be symlinks to other:

  • /bin and /usr/bin
  • /sbin and /usr/sbin
  • /lib and /usr/lib
  • /lib64 and /usr/lib6

Conclusion

By understanding the Linux filesystem hierarchy, it becomes easy to describe how Linux organizes files, and how different applications store their configuration files, logs and persistent data. It will help you become a better Linux SysAdmin.

More on Linux:

Best Linux Books for Beginners & Experts

Install Brave Web Browser on Ubuntu / Linux Mint

Best Web browsers for Windows and Linux