- 3 -
contents of directories. However, anyone with appropriate permission may read a directory just like any
other file.
The system maintains several directories for its own use. One of these is the root directory. All files
in the system can be found by tracing a path through a chain of directories until the desired file is reached.
The starting point for such searches is often the root. Other system directories contain all the programs
provided for general use; that is, all the commands. As will be seen, however, it is by no means necessary
that a program reside in one of these directories for it to be executed.
Files are named by sequences of 14 or fewer characters. When the name of a file is specified to the
system, it may be in the form of a path name, which is a sequence of directory names separated by slashes,
‘‘/’’, and ending in a file name. If the sequence begins with a slash, the search begins in the root directory.
The name /alpha/beta/gamma causes the system to search the root for directory alpha, then to search
alpha for beta, finally to find gamma in beta. gamma may be an ordinary file, a directory, or a special
file. As a limiting case, the name ‘‘/’’ refers to the root itself.
A path name not starting with ‘‘/’’ causes the system to begin the search in the user’s current direc-
tory. Thus, the name alpha/beta specifies the file named beta in subdirectory alpha of the current direc-
tory. The simplest kind of name, for example, alpha, refers to a file that itself is found in the current direc-
tory. As another limiting case, the null file name refers to the current directory.
The same non-directory file may appear in several directories under possibly different names. This
feature is called linking; a directory entry for a file is sometimes called a link. The Unix system differs
from other systems in which linking is permitted in that all links to a file have equal status. That is, a file
does not exist within a particular directory; the directory entry for a file consists merely of its name and a
pointer to the information actually describing the file. Thus a file exists independently of any directory
entry, although in practice a file is made to disappear along with the last link to it.
Each directory always has at least two entries. The name ‘‘.’’ in each directory refers to the direc-
tory itself. Thus a program may read the current directory under the name ‘‘. ’’ without knowing its com-
plete path name. The name ‘‘..’’ by convention refers to the parent of the directory in which it appears,
that is, to the directory in which it was created.
The directory structure is constrained to have the form of a rooted tree. Except for the special entries
‘‘ .’’ and ‘‘ ..’’, each directory must appear as an entry in exactly one other directory, which is its parent.
The reason for this is to simplify the writing of programs that visit subtrees of the directory structure, and
more important, to avoid the separation of portions of the hierarchy. If arbitrary links to directories were
permitted, it would be quite difficult to detect when the last connection from the root to a directory was sev-
ered.
3.3 Special files
Special files constitute the most unusual feature of the Unix file system. Each supported I/O device
is associated with at least one such file. Special files are read and written just like ordinary disk files, but
requests to read or write result in activation of the associated device. An entry for each special file resides
in directory /dev, although a link may be made to one of these files just as it may to an ordinary file. Thus,
for example, to write on a magnetic tape one may write on the file /dev/mt. Special files exist for each
communication line, each disk, each tape drive, and for physical main memory. Of course, the active disks
and the memory special file are protected from indiscriminate access.
There is a threefold advantage in treating I/O devices this way: file and device I/O are as similar as
possible; file and device names have the same syntax and meaning, so that a program expecting a file name
as a parameter can be passed a device name; finally, special files are subject to the same protection mecha-
nism as regular files.
3.4 Removable file systems
Although the root of the file system is always stored on the same device, it is not necessary that the
entire file system hierarchy reside on this device. There is a mount system request with two arguments: the
name of an existing ordinary file, and the name of a special file whose associated storage volume (e.g., a
disk pack) should have the structure of an independent file system containing its own directory hierarchy.