
In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, e ...
, a directory is a
file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
cataloging structure which contains references to other
computer file
A computer file is a computer resource for recording data in a computer storage device, primarily identified by its file name. Just as words can be written to paper, so can data be written to a computer file. Files can be shared with and transfe ...
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
A hierarchy (from Greek: , from , 'president of sacred rites') is an arrangement of items (objects, names, values, categories, etc.) that are represented as being "above", "below", or "at the same level as" one another. Hierarchy is an important ...
file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
(that is, one in which files and directories are organized in a manner that resembles a
tree
In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are ...
), 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.
Overview

Historically, and even on some modern
embedded system
An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' as ...
s, the file systems either had no support for directories at all or had only a "flat"
directory structure
In computing, a directory structure is the way an operating system arranges Computer file, files that are accessible to the user. Files are typically displayed in a hierarchical tree structure.
File names and extensions
A filename is a string use ...
, meaning subdirectories were not supported; there were 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
A path is a route for physical travel – see Trail.
Path or PATH may also refer to:
Physical paths of different types
* Bicycle path
* Bridle path, used by people on horseback
* Course (navigation), the intended path of a vehicle
* Desire p ...
.
In many
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
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
A home directory is a file system directory on a multi-user operating system containing files for a given user of the system. The specifics of the home directory (such as its name and location) are defined by the operating system involved; for ...
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
In computing, the superuser is a special user account used for system administration. Depending on the operating system (OS), the actual name of this account might be root, administrator, admin or supervisor. In some cases, the actual name of th ...
, but modern Unix usually uses another directory such as for this purpose.
In keeping with
Unix philosophy
The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system. Early Unix dev ...
, 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, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s' desktop environments. Folders are often depicted with
icon
An icon () is a religious work of art, most commonly a painting, in the cultures of the Eastern Orthodox, Oriental Orthodox, and Catholic churches. They are not simply artworks; "an icon is a sacred image used in religious devotion". The most ...
s which visually resemble physical file folders.
There is a difference between a ''directory'', which is a
file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
concept, and the
graphical user interface
The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, inste ...
metaphor that is used to represent it (a ''folder''). For example,
Microsoft Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
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, users may sometimes call it a folder.
Lookup cache
Operating systems that support hierarchical filesystems (practically all modern ones) implement a form of
caching
In computing, a cache ( ) is a hardware or software component that stores data so that future requests for that data can be served faster; the data stored in a cache might be the result of an earlier computation or a copy of data stored elsewher ...
to
RAM of recent
path
A path is a route for physical travel – see Trail.
Path or PATH may also refer to:
Physical paths of different types
* Bicycle path
* Bridle path, used by people on horseback
* Course (navigation), the intended path of a vehicle
* Desire p ...
lookups. In the
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
world, this is usually called Directory Name Lookup Cache (DNLC), although it is called dcache on
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
.
For local filesystems, DNLC 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
In computing, a directory structure is the way an operating system arranges Computer file, files that are accessible to the user. Files are typically displayed in a hierarchical tree structure.
File names and extensions
A filename is a string use ...
*
Filename
A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose different restrictions on filename lengths.
A filename may (depending on the file system) include:
* name &ndas ...
*
Filesystem Hierarchy Standard
The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of a UNIX system. It has been made popular by its use in Linux distributions, but it is used by other UNIX variants as well. It is maintained b ...
*
Home directory
A home directory is a file system directory on a multi-user operating system containing files for a given user of the system. The specifics of the home directory (such as its name and location) are defined by the operating system involved; for ...
*
Root directory
In a computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the trunk of a tree, as the starting point where all branches ...
*
Virtual folder
*
Working directory
;Commands
*
cd (command)
*
chroot
A chroot on Unix and Unix-like operating systems is an operation that changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name (and therefore normally ...
*
dir (command)
In computing, dir (directory) is a command in various computer operating systems used for computer file and directory listing. It is one of the basic commands to help navigate the file system. The command is usually implemented as an internal co ...
*
mkdir
The mkdir (make directory) command in the Unix, DOS, DR FlexOS, IBM OS/2, Microsoft Windows, and ReactOS operating systems is used to make a new directory. It is also available in the EFI shell and in the PHP scripting language. In DOS, OS/2, ...
*
pushd and popd
In computing, pushd and popd are commands used to work with the command line directory stack. They are available on command-line interpreters such as 4DOS, Bash, C shell, tcsh, Hamilton C shell, KornShell, cmd.exe, and PowerShell for op ...
*
pwd
In Unix-like and some other operating systems, the pwd command (''print working directory'') writes the full pathname of the current working directory to the standard output.
Implementations
Multics had a pwd command (which was a short name of ...
*
tree (command)
In computing, tree is a recursive directory listing command or program that produces a depth-indented listing of files. Originating in PC- and MS-DOS, it is found in Digital Research FlexOS, IBM/Toshiba 4690 OS, PTS-DOS, FreeDOS, IBM OS/2, Micros ...
References
External links
Definition of directoryby The Linux Information Project (LINFO)
{{DEFAULTSORT:Directory (computing)
Computer file systems
File system management