The Filesystem Hierarchy Standard (FHS) provides a standardized directory structure for Linux systems, promoting consistency across distributions. While not mandatory, most Linux distributions adhere to it.
Think of the filesystem as a tree, with the root directory (/) as its trunk. From this trunk, various branches (/bin, /boot, etc.) hold specific types of files. Here's a breakdown of the key directories:
- /: The root directory, containing all other directories.
- /bin: Essential command binaries accessible to all users (e.g., ls, cat, cp).
- /boot: Files required for the boot process, including the kernel and initrd.
- /dev: Device files, representing both physical and virtual devices.
- /etc: Host-specific system-wide configuration files.(e.g. nginx configuration files are in /etc/nginx )
- /home: Home directories for users, storing personal files and settings. Typically, /home/username (e.g., /home/john).
- /lib: Shared libraries essential for the system and programs in /bin and /sbin.
- /media: Mount point for removable media (e.g., USB drives, CDs).
- /mnt: Temporary mount point for filesystems mostly network attached storage (NAS)
- /opt: Optional application software packages.
- /root: Home directory for the root user.
- /run: Runtime variable data, including process IDs.
- /sbin: System binaries, often used for system administration (root-only commands).
- /srv: Data served by the system (e.g., web server content).
- /tmp: Temporary files, often cleared on boot.
- /usr: Read-only user data.
- /proc: Virtual filesystem with information about running processes.
- /var: Variable data written during system operation (e.g., logs, caches, printing spools).
Important Note: Some directories, like /etc, /usr, and /var, have their own complex sub-directory hierarchies.
Temporary files are used briefly by programs and can include data like:
- Running process data
- Crash logs
- Autosave files
- Cache files
The FHS defines specific locations for temporary files:
- /tmp: For temporary files that can be deleted on boot.
- /var/tmp: For temporary files preserved between reboots.
- /run: For runtime variable data, cleared on boot.
While programs can technically create temporary files anywhere, following the FHS guidelines ensures consistency and predictable behavior.