LINFO

Directory Definition



The term directory is used in a computer software context to refer to what appears to the user to be a container or folder1 that can hold files and other directories.

A file is a named collection of related data that appears to the user as a single, contiguous block of information and that is retained in storage. Storage refers to computer devices or media which can retain data for relatively long periods of time (e.g., years or decades), such as hard disk drives (HDDs), CDROMs and magnetic tape.

In Linux and other Unix-like operating system, everything on the system is treated as being a file, and a directory is thus considered to be just a special type of file that contains a list of file names and the corresponding inodes for each file and directory that it appears to contain. An inode is a data structure on a filesystem that stores all the information about a file except its name and its actual data.

Therefore, it can be useful to think of the word directory as being an abbreviation for the term directory file. Although perhaps technically redundant, it is convenient and common to use expressions such as files and directories when referring to the contents of a directory2; an alternative is filesystem objects.

Directories play a key role in hierarchical filesystems, which are fundamental to modern computer operating systems, by allowing the grouping of directories and files in order to organize the filesystem into a modular hierarchy. This gives the filesystem structure flexibility and depth; it also facilitates searching for data and adds to the robustness of data storage.

At the top of this hierarchy is the root directory, which is the single directory on a Unix-like operating system that contains all other directories and which is represented by a forward slash. Every directory, except for the root directory, has one parent directory (i.e., a directory in which it is contained). Any directory can have one or more child directories, also referred to as subdirectories. Every directory is also a subdirectory except for the root directory.

An empty directory is a directory that does not contain any subdirectories or files other than the two special files that automatically exist in every directory on a Unix-like operating system. One, which is designated by a single dot, represents the directory itself. The other, which is designated by two dots, represents its parent directory. In GUIs (graphical user interfaces), these files are often by default set as hidden files, which are filesystem objects that are not normally visible to the user but which remain visible to the operating system.

Every user is always working within a directory. Whichever directory a user is currently working in is that user's current directory. The name of the current directory is usually obvious, but it can also be found by using the pwd (i.e., present working directory) command. The current directory can be changed with the cd (i.e., change directory) command.

There are various ways of creating and deleting directories. When using the command line (i.e., all-text mode), directories can be created with the mkdir command, and they can be removed with the rmdir and rm commands.

In the command line, any directory other than the root directory is represented by its name followed by a forward slash on most operating systems (but by a backslash on Microsoft operating systems). In GUIs on most operating systems, directories are typically represented by icons (i.e., small images) that resemble the manila folders3 that were formerly used in large numbers in most offices to organize paper documents.


________
1The term folder is used as a synonym for directory on the Microsoft Windows and Macintosh operating systems.

2This may appear somewhat analogous to the less-than-elegant and redundant expression animals and birds, which is sometimes used by people who are not biologists and who may not be fully aware that birds are just another type of animal (as are bats, reptiles, amphibians, fish, etc). The expression files and directories in contrast, does not sound dumb and can be useful for both new and advanced users.

3Manila folders are made from a large sheet of cardboard that has been folded in half and has a tab at the top which can be used to label the contents. They were traditionally beige, although sometimes other colors are used to differentiate categories of contents. The manila portion of the name is derived from the term manila hemp, a plant indigenous to the Philippines from which the folders were originally made.






Created November 4, 2006.
Copyright © 2006 The Linux Information Project. All Rights Reserved.