File System · 4.1

Directory Structures

Directories translate names into organisation. The structure chosen by an operating system affects sharing, naming conflicts, navigation and how easily users can find their files.

Choose a directory model

/

├── home/

├── student/

│ ├── notes.txt

│ └── projects/

│ └── os-lab.c

└── system/

The familiar hierarchy makes paths meaningful: /home/student/projects/os-lab.c.

Tree: Directories can contain subdirectories.

Directory responsibilities
Naming — Keeps file names understandable and resolves a path one directory at a time.
Grouping — Collects related files, often by user, project or purpose.
Sharing — Allows a file or folder to be referenced from more than one location when links are supported.

Real-world analogy: A campus map

A single-level directory is one crowded notice board. A tree is a campus map with buildings, floors and rooms, while an acyclic graph adds clearly marked shortcuts to shared resources.
Path names and directory operations

Absolute path

/home/student/notes.txt

Starts at the root, so it identifies one location regardless of the current directory.

Relative path

../shared/manual.pdf

Starts at the process’s current directory and uses . or .. to navigate.

Common operations include mkdir to create a directory, list to inspect entries, rename to change a name, and rmdir to remove an empty directory.

Quick quiz

1. Which structure naturally supports subdirectories?

2. What does an absolute path begin from?