The Linux file system follows the Filesystem Hierarchy Standard (FHS), which defines the directory structure and specific purpose of each component. Unlike Windows with its drive letters (C:, D:), Linux uses a unified hierarchical structure that begins from the root directory /.
File System Architecture
Fundamental Concept: Everything is a File
In Linux, everything is represented as a file: hardware devices, processes, network connections, and of course, regular files. This philosophy simplifies system interaction and provides a uniform interface.
Main System Directories
1. / (Root Directory)
- Purpose: System root directory
- Characteristics: Main mount point, contains all other directories
- Permissions: Only accessible by root for writing
2. /bin (Essential User Binaries)
- Content: Basic system commands available to all users
- Examples:
ls,cp,mv,cat,grep,bash - Importance: Necessary for system boot and basic operation
- Technical note: These binaries must be available even in single-user mode
# Examples of commands in /bin
ls -la /bin/ls # List command
file /bin/bash # Bash shell
which cp # Locate copy command
Code language: PHP (php)
3. /boot (Boot Loader Files)
- Key components:
- vmlinuz: Compressed Linux kernel
- initrd/initramfs: Initial RAM file system
- grub/: GRUB bootloader configuration
- config-: Kernel configuration
- Considerations: Critical for booting, requires regular backup
4. /dev (Device Files)
- Device types:
- Block devices:
/dev/sda,/dev/nvme0n1(storage) - Character devices:
/dev/tty,/dev/null(terminals, special devices) - Pseudo-devices:
/dev/zero,/dev/random
- Block devices:
# Practical examples
lsblk # List block devices
ls -l /dev/sd* # SATA/SCSI disks
cat /proc/devices # Devices registered in kernel
Code language: PHP (php)
5. /etc (Configuration Files)
- Organized structure:
/etc/passwd: User database/etc/group: Group information/etc/hosts: Local name resolution/etc/fstab: File system table/etc/systemd/: Systemd service configuration/etc/network/: Network configuration (Debian/Ubuntu)
# Useful commands for /etc
sudo find /etc -name "*.conf" -type f # Search configuration files
grep -r "hostname" /etc/ # Search hostname configurations
Code language: PHP (php)
6. /home (User Home Directories)
- Typical structure per user:
.bashrc: Bash shell configuration.ssh/: SSH keys and configurationDesktop/,Documents/,Downloads/: Standard XDG directories
- Permissions: Each user has full control over their home directory
7. /lib and /lib64 (Shared Libraries)
- Purpose: Essential shared libraries for the system
- lib vs lib64: 32-bit vs 64-bit libraries
- Important content:
libc.so: Standard C libraryld-linux.so: Dynamic linker- Kernel modules in
/lib/modules/
# Check program libraries
ldd /bin/ls # Library dependencies
ldconfig -p | grep libc # Library cache
Code language: PHP (php)
8. /media and /mnt (Mount Points)
/media: Automatic mounting of removable devices/mnt: Manual temporary mounting of file systems- Modern usage:
/mediamanaged by systems like udisks2
9. /opt (Optional Software)
- Philosophy: Third-party software installed as complete packages
- Structure:
/opt/[vendor]/[application] - Examples: Google Chrome, commercial applications, packaged software
10. /proc (Process Information Filesystem)
- Nature: Virtual file system (takes no disk space)
- System information:
/proc/cpuinfo: Processor information/proc/meminfo: Memory information/proc/[PID]/: Specific process information/proc/sys/: Configurable kernel parameters
# Examples of /proc usage
cat /proc/version # Kernel version
cat /proc/uptime # System uptime
ls /proc/[PID]/ # Information about a specific process
Code language: PHP (php)
Additional Important Directories
/root (Root User Home)
- Root user’s home directory
- Separated from
/homefor security reasons - Accessible only with root privileges
/sbin (System Binaries)
- System administration commands
- Examples:
fdisk,iptables,systemctl - Traditionally root-only, though some are accessible to normal users
/srv (Service Data)
- Data served by the system
- Suggested structure:
/srv/[service]/ - Examples:
/srv/www/,/srv/ftp/
/sys (System Filesystem)
- Virtual file system for kernel information
- Sysfs interface for devices and drivers
- Complements
/procwith more structured information
/tmp (Temporary Files)
- Temporary files for system and applications
- Cleaned periodically (boot or tmpfiles)
- Special permissions (sticky bit) for multi-user security
/usr (User System Resources)
- Important secondary structure:
/usr/bin: User commands (non-essential)/usr/sbin: Administration commands (non-essential)/usr/lib: Libraries for programs in/usr/binand/usr/sbin/usr/local: Locally installed software/usr/share: Shared data (documentation, icons, etc.)
/var (Variable Data)
- Data that changes during operation:
/var/log: System log files/var/cache: Application cache data/var/spool: Data queues (mail, printing)/var/lib: Persistent application state data/var/run: Runtime data (PID files)
Best Practices and Security Considerations
Mounting and Permissions
# Check mount points
mount | column -t
df -h # Space usage by file system
findmnt # Tree view of mounts
Code language: PHP (php)
Efficient Navigation
# Useful navigation commands
find / -name "config" -type f 2>/dev/null # Search configuration files
locate filename # Fast search (requires updatedb)
which command # Locate binaries in PATH
whereis program # Locate binaries, sources and manuals
Code language: PHP (php)
Backup and Maintenance
- Critical directories for backup:
/etc,/home,/var/lib,/opt - Directories that DON’T need backup:
/tmp,/proc,/sys,/dev - Recommended strategy: Incremental backup of user data and configurations
Differences Between Distributions
Red Hat/CentOS/Fedora
- Network configuration in
/etc/sysconfig/network-scripts/ - SELinux contexts in
/etc/selinux/
Debian/Ubuntu
- Network configuration in
/etc/network/(traditional) or/etc/netplan/(Ubuntu 18+) - Specific directories like
/etc/apt/
Arch Linux
- Minimalist philosophy, fewer populated directories by default
- Centralized configuration in
/etc/
Diagnostic and Monitoring Tools
# File system analysis
du -sh /* # Space usage by root directory
ncdu / # Interactive disk usage analysis
lsof # Files opened by processes
fuser -v /path # Processes using a file/directory
Code language: PHP (php)
Conclusion
The Linux file system provides a logical and predictable structure that, once understood, greatly facilitates system administration. Adherence to FHS ensures consistency across distributions and facilitates portability of scripts and knowledge.
Key points to remember:
- The structure is hierarchical and unified
- Each directory has a specific and well-defined purpose
- Understanding this structure is fundamental for efficient administration
- Command-line tools leverage this organization to provide powerful and flexible functionality
Mastery of the Linux file system is the foundation for becoming a competent system administrator and a more efficient developer in Unix-like environments.
image via LinkedIN
