Linux/Unix: A Deep Dive into the File System Structure

In Linux/Unix, the file system is structured as a hierarchical directory tree. Here's an overview of the standard directory structure and what each directory is commonly used for:

  1. / (Root): This is the base of the file system. All other directories, files, drives, and devices are attached to this root. Only the root user has the permission to write directly to this directory.
  2. /bin (User Binaries): Contains essential user command binaries (programs) that need to be available in single-user mode and to all users, such as ls, cp, mv, rm, etc.
  3. /sbin (System Binaries): Like /bin, this directory holds binaries that are essential to the system, but which are usually not executed by normal users. These are system administration commands, such as fdisk, fsck, init, etc.
  4. /etc (Configuration Files): Hosts the system-wide configuration files. It contains no binary programs, but scripts that start each system service at boot time.
  5. /dev (Device Files): Contains device files which are special files that help the system to access hardware like HDDs, SSDs, keyboards, cameras, etc.
  6. /proc (Process Information): A virtual filesystem that provides a mechanism for the kernel to send information to processes. It doesn't contain 'real' files but runtime system information (e.g., system memory, devices mounted, hardware configuration, etc).
  7. /var (Variable Files): Contains files that are expected to grow in size, such as logs (/var/log), spool files, and temporary files required across reboots.
  8. /tmp (Temporary Files): Intended for storage of temporary files which are cleared when the system is rebooted.
  9. /usr (User Programs): Contains the majority of user utilities and applications, such as:
    • /usr/bin: Non-essential command binaries for all users.
    • /usr/sbin: Non-essential system binaries, e.g., daemons for various network-services.
    • /usr/local: Tertiary hierarchy for local data, specific to this host. Typically has further subdirectories, e.g., bin, sbin, etc, share.
  10. /home (Home Directories): Contains the personal directories of all users. Each user has a directory within /home with their username.
  11. /boot (Boot Loader Files): Contains the files needed to boot the system, such as the Linux kernel, initrd image, and boot loader configuration files (like GRUB).
  12. /lib (System Libraries): Contains shared library images required to boot the system and run the commands in the root filesystem, similar to /bin.
  13. /opt (Optional Add-on Applications): Reserved for the installation of add-on application software packages.
  14. /mnt (Mount Directory): Used to mount temporary filesystems, like a CD-ROM or a floppy.
  15. /media (Removable Media): This is where removable media devices such as USB drives, CD-ROMs, etc., are mounted.
  16. /srv (Service Data): Contains data for services provided by the system.
  17. /root (Root Home Directory): This is the home directory for the root user.
  18. /lost+found: This directory is used by the system to recover files after a file system check has been performed and typically exists at the root of each partition.
graph TD; /-->|contains|bin[Binaries] /-->|contains|sbin[System Binaries] /-->|contains|etc[Configuration Files] /-->|contains|dev[Device Files] /-->|contains|proc[Process Information] /-->|contains|var[Variable Files] /-->|contains|tmp[Temporary Files] /-->|contains|usr[User Programs] /-->|contains|home[Home Directories] /-->|contains|boot[Boot Loader Files] /-->|contains|lib[System Libraries] /-->|contains|opt[Optional Add-on Applications] /-->|contains|mnt[Mount Directory] /-->|contains|media[Removable Media] /-->|contains|srv[Service Data] /-->|contains|root[Root Home Directory] /-->|contains|lost+found[Recovery Directory] usr-->|contains|usr_bin[usr/bin] usr-->|contains|usr_sbin[usr/sbin] usr-->|contains|usr_local[usr/local] usr_local-->|contains|local_bin[local/bin] usr_local-->|contains|local_sbin[local/sbin] usr_local-->|contains|local_etc[local/etc] usr_local-->|contains|local_share[local/share] var-->|contains|log[Logs] var-->|contains|spool[Spool Files] var-->|contains|tmp[Temporary Files]

Each directory has a specific purpose and contains a certain type of files, which helps in system organization and efficiency. This structure is defined by the Filesystem Hierarchy Standard (FHS), which most Linux distributions follow.

Subscribe to our "Newsletter"

Leave a Comment

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

Scroll to Top