Log in Sign up
Back to Discover
💻

Directory (computing)

technology Maturity 7-9

A computer has many files. You can put them in folders. These folders help you stay neat. It is like a desk with drawers. Folders keep your things in one place. This makes finding things easy. Do you use folders?

41 words

Computers have many files. You can put files in folders. This helps you stay neat. It is like a desk with drawers.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg
You can put a folder inside another folder. We call the small one a child. The big one is the parent. The very top folder is the root. It has no parent. This helps you find your work fast.
Dir command in Windows Command Prompt.png
Dir command in Windows Command Prompt.png
Folders keep things in order.

74 words

Computers store many files. A directory helps keep them in order. You might know them as folders. A folder is like a drawer in a desk. It holds files or even other folders.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg

Many computers use a tree shape to organize things. This is called a hierarchical file system. In this system, a folder inside another is a subdirectory. The folder that holds it is the parent. The very top folder is the root directory. It has no parent of its own.

To find a file, the computer follows a path. A path is a list of places to go.

Dir command in Windows Command Prompt.png
Dir command in Windows Command Prompt.png
Some programs use a working directory. This is the place where the program stays to do its work. If you do not name a specific folder, the computer looks there. This helps you find your files quickly. Computers also use a cache to work faster. A cache is a way to remember paths in the computer's memory. This means the computer does not have to search the whole tree every time.

179 words

Computers store many different files every day. A directory is a special structure used to catalog these files. You might know them as folders. This name comes from office folders used to hold papers. A directory can hold references to files or even other directories. This helps keep related things together in one place. It is a way to keep a computer organized.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg

Many systems use a tree-like way to organize data. This is called a hierarchical file system. In this system, a directory inside another is a subdirectory. The folder that holds the subdirectory is called the parent. The very top directory is the root directory. It has no parent of its own.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg
To find something, the computer follows a path. A path is a reference to a specific location. Most files can only live in one directory at a time.

People have used different names for this for a long time. The folder idea was used in a machine called the ERMA Mark 1 in 1958. Later, the Xerox Star system also used the folder name. In early Unix systems, the root directory was the home for the root user. Modern Unix systems usually use a different directory for that job. Today, most people use a graphical interface to see folders. This makes it easier to manage files without typing long paths.

Different computer systems handle directories in their own ways. Windows uses special folders to help users find things easily.

Dir command in Windows Command Prompt.png
Dir command in Windows Command Prompt.png
Linux uses a structure called dcache to help the system work fast. This dcache stores directory entries in the computer's memory. Other systems like macOS and BSD also use lookup caches. These caches help the computer remember paths. This means the computer does not have to search the whole tree every time.

Think about a large library with many different rooms. Each room might have many shelves for different books.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg
The directory is like the library's catalog system. It tells you exactly which shelf holds your book. Some programs even have a working directory. This is like a desk where a librarian stays to work. If a program needs a file, it looks at that desk first. This makes finding information much faster for the computer.

380 words

A directory is a vital cataloging structure used by computer file systems. It contains references to other computer files and can also contain other directories.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg
This structure allows a computer to organize vast amounts of data efficiently. Without directories, finding a specific piece of information would be extremely difficult. The name comes from real-world examples like a telephone directory. Just as a phone book lists names and numbers, a directory lists files and their locations.

Most modern computers use a hierarchical file system to manage data. This system is organized like a tree structure. In this model, a directory contained inside another directory is called a subdirectory. The relationship between these two is often described using biological terms. The containing directory is called the parent, while the contained directory is the child.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg
At the very top of this entire structure sits the root directory. The root directory is unique because it does not have a parent of its own. A reference to a specific location within this hierarchy is known as a path.

Directories can be understood through different metaphors depending on how you interact with them. In a graphical user interface, users often see directories as "folders." This visual metaphor uses icons that look like physical office folders. However, there is a technical difference between the two. A directory is a fundamental file system concept. A folder is a graphical representation used to make that concept easier for humans to navigate. Some systems even use "smart folders," which are virtual and reflect the results of a search rather than a physical location in the hierarchy.

History shows how these organizational concepts have evolved over time. The folder metaphor was used as early as 1958. It appeared in the design for the Electronic Recording Machine, Accounting (ERMA) Mark 1. Later, the Xerox Star system also utilized this folder concept. In early versions of the Unix operating system, the root directory served as the home directory for the root user. Modern Unix systems have changed this, usually using a different directory for that specific purpose. In Unix philosophy, the system actually treats directories as a special type of file.

To make file access faster, operating systems use a mechanism called a lookup cache. This process stores information in the computer's RAM, which is much faster than searching the entire disk.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg
In Unix-like systems, this is often called the directory name lookup cache, or DNLC. The cache stores mappings between path components, such as "/usr/bin," and their corresponding directory objects. By using fast structures like hash tables or radix trees, the system can bypass a full traversal of the file hierarchy. This dramatically improves performance for tasks that involve heavy metadata operations.

Different operating systems implement these caching and directory methods uniquely. The Linux kernel uses a structure called the dcache within its Virtual File System layer.

Dir command in Windows Command Prompt.png
Dir command in Windows Command Prompt.png
Each dentry in the dcache links to an inode and can represent a file or a subdirectory. These entries are stored in memory as long as there is no memory pressure. Other systems like macOS integrate lookup caching into their VFS layer. BSD variants, such as FreeBSD and OpenBSD, also implement their own directory lookup caches. Windows uses internal path caching within its NTFS and kernel object manager layers.

Managing directories becomes more complex in distributed file systems, such as NFS or AFS. In these systems, the cache must remain "coherent" across many different clients. This means that if one user changes a file, the change must be reflected in the caches of all other users.

Files11 directory hierarchy.svg
Files11 directory hierarchy.svg
To prevent errors or data loss, these systems use mechanisms like attribute timeouts or lease-based locking. If the system fails to maintain this coherence, it can result in stale metadata or incorrect path resolution. Properly optimized caches can lead to massive performance gains. In some benchmarks, they have shown orders-of-magnitude improvements in system boot times and file access speeds.

663 words
🖼️ Images & Media (2)
File:Dir command in Windows Command Prompt.png
Dir command in Windows Command Prompt.png
File:Files11_directory_hierarchy.svg
Files11_directory_hierarchy.svg
Up Next
💻
Tree (abstract data type)
Technology
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.