Directory Structure Explained

A Directory Is Just a Special Kind of File

A directory isn't fundamentally different storage from a regular file - it's simply a file whose specific contents are a list of other files (and other directories) it contains, along with information about where to find each one's actual data.

Single-Level Directory: The Simplest, Most Limited Structure

/  ---  file1, file2, file3, file4  (everything in one single flat list)

All files exist in one single, flat list with no subdirectories at all - simple, but every single file needs a completely unique name, and organizing a large number of files this way quickly becomes genuinely impractical.

Two-Level Directory: One Level of Separation Per User

/
  user1  ---  file1, file2
  user2  ---  file1, file3

Each user gets their own separate directory - file names only need to be unique within a single user's own directory, solving the naming collision problem of a single-level structure, but still not allowing any further nested organization within a user's own files.

Tree-Structured Directory: The Familiar, Fully Nested Approach

/
  home/
    user1/
      documents/
        report.txt
      photos/
  var/
    logs/

Directories can contain other directories, nested to any depth - the familiar, flexible folder structure used by virtually every modern operating system, allowing files to be organized as deeply and logically as actually needed.

Absolute Paths vs Relative Paths

Path typeExampleMeaning
Absolute/home/user1/documents/report.txtThe complete path, starting from the root directory
Relativedocuments/report.txtInterpreted relative to whatever the current directory happens to be

Why Tree Structure Became the Universal Standard

The tree structure's ability to organize files as deeply and logically as needed - while still keeping the naming and lookup problems of flatter structures fully solved - is exactly why virtually every general-purpose operating system in use today adopts some variation of this same nested, hierarchical directory model.

Written by Lorens Mishra

Software Engineer Notes Management System Administrator

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.