Filesystems · foundation

Filesystem hierarchy

A Unix filesystem hierarchy is a single tree of pathnames rooted at /. Mounted filesystems attach additional filesystem trees at directories within that namespace.

Why it matters

Absolute and relative paths, mount points, configuration locations, device nodes, and temporary data all make more sense when viewed as one pathname tree rather than as independent drive letters.

Mental model

How to reason about filesystem hierarchy

Path lookup starts either at / or at the process's current directory and resolves one component at a time. Crossing a mount point continues lookup in a different filesystem without changing the pathname syntax.

Analogy

The hierarchy is like one city map assembled from districts: every address starts from the same map origin, while a district boundary may switch to a separately maintained map underneath.

Examples

See the boundary, not just the happy path

Worked example · Resolve an absolute path

/var/log/app/server.log

The leading slash starts lookup at the process's root directory. Each component must name a traversable directory until the final server.log entry is reached.

Worked example · Inspect filesystem boundaries

findmnt --target /home/alex/project

On Linux, findmnt reports which mounted filesystem supplies the target path. A normal-looking directory can be a mount point backed by another device or virtual filesystem.

Useful contrast · A pathname need not name stored file data

/dev/null

/dev/null occupies a place in the hierarchy but is a device node whose operations are implemented by the kernel, not an ordinary file containing persistent bytes.

Common mistakes

Misconceptions to remove early

Treating / as the physical machine's universal root

A process can have a changed root or a mount namespace, as in containers. The pathname / is the root visible to that process, which may differ from another process's view.

Assuming directory conventions are identical everywhere

Standards and conventions describe common roles, but operating systems and distributions vary. Inspect the target system rather than inferring behavior solely from a familiar path.

Quick check

Can you predict the result?

1. What changes during pathname lookup when it reaches a mount point?
  • Lookup continues in the filesystem mounted at that directory.
  • The path becomes relative to the user's home directory.
  • The kernel converts the path to a drive-letter path.
Answer: Lookup continues in the filesystem mounted at that directory.
2. Where does resolution of the relative path logs/app.log begin?
Answer: At the calling process's current working directory.

Keep building

Authoritative references

Make the idea retrievable.

Study this concept with spaced repetition, next to the commands where you use it.

Get Terminaster