Linux Directory Architecture
Filesystem Hierarchy Standard (FHS) overview
Linux follows the Filesystem Hierarchy Standard (FHS), which defines the structure and purpose of directories. This standardization ensures consistency across distributions and helps both users and developers understand where files belong. Every directory has a specific purpose, from storing essential system binaries to user data and configuration files.
Understanding this structure is crucial for system administration. For example, system binaries are typically in /bin or /usr/bin, while configuration files that control system behavior are located in /etc. User files and applications often reside in /home, while log files and other variable data are stored in /var.
Key Directories
- /etc — System-wide config
- /var/log — Log files
- /usr/bin — User binaries
- /opt — Third-party software
- /tmp — Temporary (cleared on reboot)
Virtual Filesystems
- /proc — Process & kernel info
- /sys — Hardware & drivers
- /dev — Device nodes
- /run — Runtime state
Some directories like /proc and /sys are virtual filesystems that don't actually exist on disk. They provide interfaces to kernel and system information, allowing you to interact with the system through filesystem-like operations. It's important to follow FHS conventions to maintain system stability and ensure compatibility across different Linux distributions.
Best Practices
- Never write to / or /usr directly
- User data goes in /home or /var
- Configs belong in /etc
- Logs should be in /var/log