Skip to main content

Important Directories in Linux File System

Linux organizes its file system in a hierarchical structure, starting from the root directory (/). Each directory serves a specific purpose, ensuring a clear and organized layout. Here’s an overview of the most important directories in the Linux file system:


Important Directories in Linux

  1. / (Root Directory)

    • The topmost directory in the Linux file system.
    • All other directories and files stem from this directory.
    • Accessible only by the root user for critical modifications.
  2. /bin (Binary Files)

    • Contains essential binary executables used by all users.
    • Examples include common commands like ls, cat, cp, mv, etc.
    • These binaries are available even in single-user mode (emergency mode).
  3. /boot (Boot Loader Files)

    • Stores files needed to boot the operating system, including:
      • Kernel files (vmlinuz).
      • Boot loader configurations (e.g., GRUB files).
    • Example: /boot/grub/grub.cfg.
  4. /dev (Device Files)

    • Contains device files representing hardware devices (e.g., disks, printers, terminals).
    • Examples:
      • /dev/sda: First hard drive.
      • /dev/tty: Terminal devices.
      • /dev/null: Null device for discarding output.
  5. /etc (Configuration Files)

    • Stores system-wide configuration files and scripts.
    • Examples:
      • /etc/passwd: User account details.
      • /etc/fstab: Filesystem mount points.
      • /etc/hosts: IP-to-hostname mappings.
  6. /home (User Home Directories)

    • Contains the personal directories for each user.
    • Example:
      • /home/alice: Home directory for the user alice.
    • Users store their personal files, configurations, and documents here.
  7. /lib (Shared Libraries)

    • Contains essential shared libraries required by programs in /bin and /sbin.
    • Example: /lib/libc.so.6.
  8. /media (Removable Media)

    • Mount point for removable media, such as USB drives, CDs, and DVDs.
    • Example: /media/usb.
  9. /mnt (Temporary Mount Points)

    • Temporary mount point for filesystems during manual mounting.
    • Commonly used for system administrators to mount disks temporarily.
  10. /opt (Optional Software)

    • Used to install third-party or optional software packages.
    • Example: /opt/vmware for VMware-related files.
  11. /proc (Process Information)

    • Virtual filesystem providing information about running processes.
    • Examples:
      • /proc/cpuinfo: CPU details.
      • /proc/meminfo: Memory usage.
      • /proc/[pid]: Information about a specific process.
  12. /root (Root User's Home Directory)

    • Home directory for the root user (superuser).
    • Different from / (root directory).
  13. /run (Runtime Data)

    • Stores runtime data for system processes since boot time.
    • Examples: Process IDs, sockets, and other transient files.
  14. /sbin (System Binaries)

    • Contains essential system binaries for administrative tasks.
    • Examples:
      • ifconfig: Network configuration.
      • fsck: Filesystem check.
  15. /srv (Service Data)

    • Stores data for services provided by the system (e.g., web servers, FTP).
    • Example: /srv/www for web server data.
  16. /sys (System Information)

    • Virtual filesystem providing information about hardware devices and system settings.
    • Example:
      • /sys/class/net: Network interface details.
  17. /tmp (Temporary Files)

    • Temporary files created by users and applications.
    • Automatically cleaned up after a reboot.
  18. /usr (User System Resources)

    • Contains user-level programs, libraries, and documentation.
    • Subdirectories include:
      • /usr/bin: User binaries.
      • /usr/lib: Shared libraries.
      • /usr/share: Shared resources (e.g., man pages).
      • /usr/local: Locally installed software.
  19. /var (Variable Files)

    • Contains files that change frequently during system operation.
    • Examples:
      • /var/log: Log files.
      • /var/spool: Email and print jobs.
      • /var/tmp: Temporary files.

Summary Table

DirectoryPurpose
/Root directory, top of the hierarchy.
/binEssential command binaries.
/bootBoot loader and kernel files.
/devDevice files for hardware.
/etcSystem-wide configuration files.
/homeUser home directories.
/libEssential shared libraries.
/mediaMount points for removable media.
/mntTemporary mount points.
/optOptional third-party software.
/procVirtual filesystem for process info.
/rootHome directory for the root user.
/runRuntime process data.
/sbinSystem administration binaries.
/srvData for system services.
/sysVirtual filesystem for system info.
/tmpTemporary files.
/usrUser binaries, libraries, and docs.
/varVariable data like logs and spools.

Key Notes

  1. The Linux file system is modular, ensuring separation of concerns.
  2. Never modify critical directories (/bin, /lib, /sbin, /etc) unless absolutely necessary.
  3. Use /tmp for temporary data and /home for user files.

Understanding these directories helps in navigating, configuring, and administering Linux systems effectively.

Comments