🐧Linux/Unix: Introduction & Fundamentals
Estimated reading: 4 minutes 26 views

πŸ“ Linux: File System Hierarchy – Understanding Linux Directory Structure

🧲 Introduction – Why Learn the Linux File System Hierarchy?

The Linux file system is more than just foldersβ€”it’s a well-organized, logical hierarchy designed for both simplicity and scalability. Understanding this structure is essential for system navigation, software installation, permission control, and troubleshooting. Unlike Windows, everything in Linux is a file, including hardware and processes.

🎯 In this guide, you’ll learn:

  • The purpose of each top-level directory in Linux
  • How Linux treats files, directories, and devices
  • Common paths used by users, admins, and developers
  • Best practices for file storage and configuration

πŸ—‚οΈ Overview: Linux Directory Structure

The Linux file system is rooted at / (root directory) and branches out like a tree. Below is a simplified overview:

/
β”œβ”€β”€ bin
β”œβ”€β”€ boot
β”œβ”€β”€ dev
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”œβ”€β”€ lib
β”œβ”€β”€ media
β”œβ”€β”€ mnt
β”œβ”€β”€ opt
β”œβ”€β”€ proc
β”œβ”€β”€ root
β”œβ”€β”€ run
β”œβ”€β”€ sbin
β”œβ”€β”€ srv
β”œβ”€β”€ sys
β”œβ”€β”€ tmp
β”œβ”€β”€ usr
└── var

Let’s explore each of these in detail.


πŸ“‚ / – Root Directory

  • The top-most directory in Linux.
  • All other directories stem from here.
  • Equivalent to C:\ in Windows.

πŸ”§ /bin – Essential User Binaries

  • Contains essential binary commands needed for system boot and repair.
  • Common commands: ls, cp, mv, cat, mkdir

πŸ§ͺ Example:

/bin/ls

βš™οΈ /sbin – System Binaries

  • Contains system administration binaries.
  • Commands typically used by root user: fsck, reboot, ifconfig

πŸ“¦ /lib, /lib64 – Shared Libraries

  • Essential libraries for binaries in /bin and /sbin.
  • Think of them as Linux’s DLLs (like in Windows).

🧩 /etc – Configuration Files

  • System-wide configuration files live here.
  • Examples: /etc/passwd, /etc/ssh/sshd_config, /etc/fstab

πŸ§ͺ View hostname config:

cat /etc/hostname

🏠 /home – User Home Directories

  • Personal folders for users.
  • Files, downloads, and settings are stored here (e.g., /home/john).

πŸ‘‘ /root – Root User’s Home

  • Home directory for the root (superuser).
  • Not to be confused with /.

πŸ§ͺ Access only via:

sudo su
cd /root

πŸ’Ύ /boot – Boot Loader Files

  • Contains files needed to boot the OS.
  • Includes the Linux kernel (vmlinuz), initrd, and grub.

⚠️ Caution: Modifying this folder can make the system unbootable.


πŸ–₯️ /dev – Device Files

  • Represents devices as files.
  • Includes: /dev/sda (hard disk), /dev/null, /dev/tty

πŸ§ͺ Example:

ls /dev

🧠 /proc – Process & Kernel Information

  • Virtual file system providing real-time system info.
  • Files like /proc/cpuinfo, /proc/meminfo, and /proc/uptime

πŸ§ͺ View CPU Info:

cat /proc/cpuinfo

πŸ“€ /sys – System and Hardware Info

  • Similar to /proc, but for devices and drivers.
  • Used by the kernel and udev.

πŸ“ /run – Runtime Variable Data

  • Stores temporary runtime data like PID files, sockets.
  • Cleared at every reboot.

πŸ“ /tmp – Temporary Files

  • Used by apps and users to store temporary files.
  • Automatically cleared after reboot.

πŸ“¦ /opt – Optional Software Packages

  • Used for installing third-party software not from default repos.
  • E.g., /opt/google/chrome for Google Chrome.

🌐 /srv – Service Data

  • Contains files related to system services like ftp, httpd.

πŸ”Œ /mnt and /media – Mount Points

DirectoryUsage
/mntTemporary mount points (manually mounted devices)
/mediaAuto-mounted removable devices (USB, CD-ROM)

πŸ§ͺ Example:

mount /dev/sdb1 /mnt

πŸ“Œ Summary – Recap & Next Steps

The Linux file system hierarchy is designed for modularity, security, and predictability. Mastering it helps you navigate, configure, and troubleshoot like a pro. Each directory has a dedicated role, which contributes to system stability and organization.

πŸ” Key Takeaways:

  • Everything starts at / and branches downward.
  • /etc = config, /home = users, /bin = essential binaries, /boot = boot files.
  • Device files (/dev), process info (/proc), and temporary data (/tmp) are managed by the kernel.
  • Understanding the file system helps in backups, scripting, permissions, and system recovery.

❓ FAQs

❓ What is the root directory in Linux?
βœ… The root directory / is the base of the Linux file system. All other files and directories are placed under it.

❓ What’s the difference between /bin and /sbin?
βœ… /bin contains essential user commands; /sbin holds administrative/system commands for root users.

❓ Where are user files stored in Linux?
βœ… In the /home/username/ directory. Each user gets their own subfolder.

❓ What is /proc used for?
βœ… /proc is a virtual filesystem that displays system and process info directly from kernel memory.

❓ Can I delete files in /tmp?
βœ… Yes, but it’s usually cleared automatically on reboot. Use with care during active sessions.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

πŸ”΅ Linux: File System Hierarchy

Or Copy Link

CONTENTS
Scroll to Top