Unix filesystem


In Unix and operating systems inspired by it, the file system is considered a central component of the operating system. It was also one of the first parts of the system to be designed and implemented by Ken Thompson in the first experimental version of Unix, dated 1969.
As in other operating systems, the filesystem provides information storage and retrieval, and one of several forms of interprocess communication, in that the many small programs that traditionally form a Unix system can store information in files so that other programs can read them, although pipes complemented it in this role starting with the Third Edition. Also, the filesystem provides access to other resources through so-called device files that are entry points to terminals, printers, and mice.
The rest of this article uses Unix as a generic name to refer to both the original Unix operating system and its many workalikes.

Principles

The filesystem appears as one rooted tree of directories. Instead of addressing separate volumes such as disk partitions, removable media, and network shares as separate trees, such volumes can be mounted on a directory, causing the volume's file system tree to appear as that directory in the larger tree. The root of the entire tree is denoted /.
In the original Bell Labs Unix, a two-disk setup was customary, where the first disk contained startup programs, while the second contained users' files and programs. This second disk was mounted at the empty directory named usr on the first disk, causing the two disks to appear as one filesystem, with the second disk’s contents viewable at /usr.
Unix directories do not contain files. Instead, they contain the names of files paired with references to so-called inodes, which in turn contain both the file and its metadata. Multiple names in the file system may refer to the same file, a feature termed a hard link. The mathematical traits of hard links make the file system a limited type of directed acyclic graph, although the directories still form a tree, as they typically may not be hard-linked.

File types

The original Unix file system supported three types of files: ordinary files, directories, and "special files", also termed device files. The Berkeley Software Distribution and System V each added a file type to be used for interprocess communication: BSD added sockets, while System V added FIFO files.
BSD also added symbolic links to the range of file types, which are files that refer to other files, and complement hard links. Symlinks were modeled after a similar feature in Multics, and differ from hard links in that they may span filesystems and that their existence is independent of the target object. Other Unix systems may support additional types of files.

Conventional directory layout

Certain conventions exist for locating some kinds of files, such as programs, system configuration files, and users' home directories. These were first documented in the hier man page since Version 7 Unix; subsequent versions, derivatives and clones typically have a similar man page.
The details of the directory layout have varied over time. Although the file system layout is not part of the Single UNIX Specification, several attempts exist to standardize it, such as the System V Application Binary Interface, the Intel Binary Compatibility Standard, the Common Operating System Environment, and Linux Foundation's Filesystem Hierarchy Standard.
Here is a generalized overview of common locations of files on a Unix operating system:
Directory or fileDescription
/The slash / character alone denotes the root of the filesystem tree.

OWIKI.org. Text is available under the Creative Commons Attribution-ShareAlike License.