수. 8월 6th, 2025

Introduction

Linux organizes files using a hierarchical directory structure defined by the Filesystem Hierarchy Standard (FHS). Unlike Windows’ drive letters (C:\, D:), Linux uses a single root (/) with unified directories. This design ensures consistency across distributions and simplifies software development. Let’s dissect the core directories!


🌳 The Root Directory (/)

The top-level directory where everything begins. Think of it as the “trunk” of a tree.


🔑 Essential Directories & Their Roles

  1. /bin (Binaries)

    • Purpose: Critical command-line tools for all users (e.g., ls, cp, bash).
    • Why it matters: Needed for system recovery (even if other partitions fail).
  2. /etc (Etcetera)

    • Purpose: Configuration files for the system and apps (e.g., /etc/passwd for user accounts, /etc/network/ for network settings).
    • ⚠️ Caution: Editing files here requires admin rights!
  3. /home

    • Purpose: Personal directories for regular users (e.g., /home/jane).
    • Key features: Stores documents, downloads, and user-specific configs (hidden files like .bashrc).
  4. /root

    • Purpose: Home directory for the root (superuser) account. Not inside /home for security.
  5. /opt (Optional)

    • Purpose: Manually installed third-party software (e.g., proprietary apps like MATLAB).

⚙️ System & Runtime Directories

  1. /sbin (System Binaries)

    • Purpose: Administrative tools for the root user (e.g., fdisk, iptables).
  2. /usr (User System Resources)

    • Purpose: Read-only user applications and libraries. Subdirectories include:
      • /usr/bin: Standard user programs.
      • /usr/lib: Shared libraries.
      • /usr/share: Architecture-independent data (e.g., fonts, docs).
  3. /var (Variable Data)

    • Purpose: Files that change frequently:
      • Logs (/var/log), emails (/var/mail), databases (/var/lib), and web content (/var/www).
  4. /tmp (Temporary Files)

    • Purpose: Volatile files deleted on reboot. All users can write here.

🧪 Special Virtual Directories

  1. /dev (Devices)

    • Purpose: Virtual files representing hardware (e.g., /dev/sda for a disk, /dev/tty for terminals).
  2. /proc (Processes)

    • Purpose: Real-time kernel/process info (e.g., /proc/cpuinfo, /proc/[PID]/status).
    • 💡 Unique: Generated on-the-fly by the kernel (not actual files!).
  3. /sys (System)

    • Purpose: Interfaces with kernel parameters for device/driver management (e.g., CPU frequency control).

📦 Other Key Directories

Directory Function
/boot Bootloader files (e.g., kernel, initramfs).
/lib Essential shared libraries for /bin and /sbin programs.
/mnt Temporary mount points for external storage (e.g., USB drives).
/media Automatic mounts for removable media (CDs, USB).
/srv Data for services (e.g., web server files).
/run Runtime data (e.g., process IDs) since last boot.

💡 Why This Structure Matters

  • Consistency: All Linux distros (Ubuntu, Fedora, etc.) follow FHS.
  • Security: Isolates critical files (e.g., /bin vs. /home).
  • Troubleshooting: Logs (/var/log) and configs (/etc) are predictable.

> Pro Tip: Use tree -L 1 / to visualize the root structure!


Conclusion

Mastering the Linux filesystem unlocks deeper control over your system. Remember:

  • User files/home
  • Configs/etc
  • Logs/var/log
  • Hardware/dev and /sys

Start exploring with cd and ls—these directories hold the keys to your OS! 🐧🔑

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다