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.
- Persistent – These are the contents which should be persistent after a reboot, e.g system and applications configuration settings.
- Runtime – Content generated by a running process; usually deleted by a reboot
- Variable / Dynamic – These content may be appended or modified by processes running in the Linux system.
- 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: |
/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