
In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
, a directory is a
file system cataloging structure that contains references to other
computer file
A computer file is a System resource, resource for recording Data (computing), data on a Computer data storage, computer storage device, primarily identified by its filename. Just as words can be written on paper, so too can data be written to a ...
s, and possibly other directories. On many computers, directories are known as folders or drawers,
analogous to a
workbench or the traditional office
filing cabinet. The name derives from books like a
telephone directory that lists the phone numbers of all the people living in a certain area.
Files are organized by storing related files in the same directory. In a
hierarchical file system (that is, one in which files and directories are organized in a manner that resembles a
tree), a directory contained inside another directory is called a subdirectory. The terms parent and child are often used to describe the relationship between a subdirectory and the directory in which it is cataloged, the latter being the parent. The top-most directory in such a filesystem, which does not have a parent of its own, is called the root directory.
The
freedesktop.org media type for directories within many
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
systems – including but not limited to systems using
GNOME,
KDE Plasma 5, or
ROX Desktop as the desktop environment – is "inode/directory". This is not an
IANA registered media type.
Overview

Historically, and even on some modern
embedded systems, the file systems either had no support for directories at all or had only a "flat"
directory structure, meaning subdirectories were not supported; there was only a group of top-level directories, each containing files. In modern systems, a directory can contain a mix of files and subdirectories.
A reference to a location in a directory system is called a
path.
In many
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
s, programs have an associated
working directory in which they execute. Typically, file names accessed by the program are assumed to reside within this directory if the file names are not specified with an explicit directory name.
Some operating systems restrict a
user's access only to their
home directory or project directory, thus isolating their activities from all other users. In early versions of Unix, the root directory was the home directory of the
root user, but modern Unix usually uses another directory such as for this purpose.
In keeping with
Unix philosophy, Unix systems treat directories as a type of file. Caveats include not being able to write to a directory file except indirectly by creating, renaming, and removing file system objects in the directory and only being able to read from a directory file using directory-specific library routines and
system calls that return records, not a byte-stream.
Folder metaphor

The name ''folder'', presenting an analogy to the
file folder used in offices, and used in a hierarchical file system design for the
Electronic Recording Machine, Accounting (ERMA) Mark 1 published in 1958 as well as by
Xerox Star,
is used in almost all modern
operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
s' desktop environments. Folders are often depicted with
icons that visually resemble physical file folders.
There is a difference between a ''directory'', which is a
file system concept, and the
graphical user interface
A graphical user interface, or GUI, is a form of user interface that allows user (computing), users to human–computer interaction, interact with electronic devices through Graphics, graphical icon (computing), icons and visual indicators such ...
metaphor that is used to represent it (a ''folder''). For example,
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
uses the concept of
special folders to help present the contents of the computer to the user in a fairly consistent way that frees the user from having to deal with absolute directory paths, which can vary between versions of Windows, and between individual installations. Many operating systems also have the concept of "smart folders" or
virtual folders that reflect the results of a file system search or other operation. These folders do not represent a directory in the file hierarchy. Many
email clients allow the creation of folders to organize email. These folders have no corresponding representation in the filesystem structure.
If one is referring to a ''container of documents'', the term ''folder'' is more appropriate. The term ''directory'' refers to the way a structured list of document files and folders are stored on the computer. The distinction can be due to the way a directory is accessed; on Unix systems, is usually referred to as a directory when viewed in a
command line console, but if accessed through a graphical
file manager
A file manager or file browser is a computer program that provides a user interface to manage computer files, files and folder (computing), folders. The most common Computer file#Operations, operations performed on files or groups of files incl ...
, users may sometimes call it a folder.
Lookup cache
Operating systems that support hierarchical filesystems (practically all modern ones) implement a form of
caching to
RAM of recent
path lookups. In the
Unix world, this is usually called Directory Name Lookup Cache (DNLC), although it is called dcache on
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
.
For local filesystems, cache entries normally expire only under pressure from other more recent entries. For
network file systems a
coherence mechanism is necessary to ensure that entries have not been invalidated by other clients.
[
]
See also
* File folder
;Concepts
* Directory structure
* Filename
* Filesystem Hierarchy Standard
* Home directory
* Root directory
* Virtual folder
* Working directory
;Commands
* cd (command)
* chroot
* dir (command)
* mkdir
* pushd and popd
* pwd
* tree (command)
References
External links
Definition of directory
by The Linux Information Project (LINFO)
{{DEFAULTSORT:Directory (computing)
Computer file systems
File system management