Lably
Skip to content

Unix filesystem

Directory structure used by a Unix-like operating system

  • 3 min read
  • 2 chapters

Related on Lably

Through Operating system, File system and Printer (computing)

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.

Directories in Unix file systems 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 (owner, permissions, time of last access, etc., but no name). 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. As originally envisioned in 1969, the Unix file system would in fact be used as a general graph with hard links to directories providing navigation, instead of path names.

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 (BSD) 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 (often termed "symlinks") 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.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Computing and communication