You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

How can I master the Linux File System Hierarchy?. 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.

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 DirectoryPurpose
/etcContains configuration files used by system services
/rootThis is a home directory for the Linux superuser account, root
/bootContains all the files needed to start the boot process.
/homeThis is where standard users store their personal configurations and data such as Documents, Videos, Music e.t.c.
/varHas variable data that is required to persist between boots – databases, log files, mails, cache directories, Web data e.t.c.
/tmpStores temporary files. All Linux users can write to this directory. Files older than 10 days are deleted automatically.
/usrThis 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.
/devThis contains special device files used by the system to access hardware.
/runThe 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

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF