

InUnix andoperating systems inspired by it, thefile system is considered a central component of the operating system.[1] It was also one of the first parts of the system to be designed and implemented byKen Thompson in the first experimental version of Unix,dated 1969.[2]
As in other operating systems, the filesystem provides information storage and retrieval, and one of several forms ofinterprocess 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, althoughpipes complemented it in this role starting with theThird Edition. Also, the filesystem provides access to other resources through so-calleddevice files that are entry points toterminals,printers, andmice.
The rest of this article usesUnix as ageneric name to refer to both the original Unix operating system and its manyworkalikes.
The filesystem appears as onerooted tree of directories.[1] Instead of addressing separate volumes such asdisk partitions, removable media, andnetwork shares as separate trees, such volumes can bemounted on a directory, causing the volume's file system tree to appear as that directory in the larger tree.[1] The root of the entire tree is denoted/.
In the originalBell 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 namedusr 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 notcontain files. Instead, they contain the names of files paired with references to so-calledinodes, which in turn contain both the file and itsmetadata (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 ahard link.[1] The mathematical traits of hard links make the file system a limited type ofdirected acyclic graph, although thedirectories 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.[2]
The original Unix file system supported three types of files: ordinary files,directories, and "special files", also termed device files.[1] TheBerkeley Software Distribution (BSD) andSystem V each added a file type to be used forinterprocess communication: BSD addedsockets,[3] while System V addedFIFO files.
BSD also addedsymbolic links (often termed "symlinks") to the range of file types, which are files that refer to other files, and complement hard links.[3] Symlinks were modeled after a similar feature inMultics,[4] 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.[5]
Certain conventions exist for locating some kinds of files, such as programs, system configuration files, and users'home directories. These were first documented in thehier(7)man page sinceVersion 7 Unix;[6] subsequent versions, derivatives and clones typically have a similar man page.[7][8][9][10][11][12]
The details of the directory layout have varied over time. Although the file system layout is not part of theSingle UNIX Specification, several attempts exist to standardize (parts of) it, such as theSystem VApplication Binary Interface, theIntel Binary Compatibility Standard, the Common Operating System Environment, andFreeDesktop'sFilesystem Hierarchy Standard (FHS).[13]
Here is a generalized overview of common locations of files on a Unix operating system:
| Directory or file | Description |
|---|---|
/ | The slash/ character alone denotes the root of the filesystem tree. |
| Stands forbinaries and contains certain fundamental utilities, such asls orcp, that are needed to mount/usr, when that is a separate filesystem, or to run in one-user (administrative) mode when/usr cannot be mounted. In System V.4, this is asymlink to/usr/bin. Otherwise, it needs to be on the root filesystem itself. |
| Contains all the files needed for successful booting process. InResearch Unix, this was one file rather than a directory.[14] Nowadays usually on the root filesystem itself, unless the system, bootloader etc. require otherwise. | |
| Stands fordevices. Containsfile representations of peripheral devices andpseudo-devices. See also:Linux Assigned Names and Numbers Authority. Needs to be on the root filesystem itself. | |
| Contains system-wide configuration files and system databases; the name stands foret cetera[14] but now a better expansion iseditable-text-configurations. Originally also contained "dangerous maintenance utilities" such asinit,[6] but these have typically been moved to/sbin or elsewhere. Needs to be on the root filesystem itself. |
| Contains user home directories on Linux and some other systems. In the original version of Unix, home directories were in/usr instead.[15] Some systems use or have used different locations still:macOS has home directories in/Users, older versions of BSD put them in/u,FreeBSD has/usr/home. |
| Originallyessential libraries:C libraries, but notFortran ones.[14] On modern systems, it contains the shared libraries needed by programs in/bin, and possiblyloadable kernel module,device drivers orbinary blobs. Linux distributions may have variants/lib32 and/lib64 for multi-architecture support. |
| Default mount point for removable devices, such as USB sticks, media players, etc. By common sense, the directory itself, whose subdirectories are mountpoints, is on the root partition itself. |
| Stands formount. Empty directory commonly used by system administrators as a temporary mount point. By common sense, the directory itself, whose subdirectories are mountpoints, is on the root partition itself. |
| Contains locally installed software. Originated inSystem V, which has apackage manager that installs software to this directory (one subdirectory per package).[16] |
| procfs virtualfilesystem showing information aboutprocesses as files. |
| The home directory for thesuperuserroot - that is, the system administrator. This account's home directory is usually on the initial filesystem, and hence not in /home (which may be a mount point for another filesystem) in case specific maintenance needs to be performed, during which other filesystems are not available. Such a case could occur, for example, if a hard disk drive suffers failures and cannot be properly mounted. |
| Stands for "system (or superuser) binaries" and contains fundamental utilities, such asinit, usually needed to start, maintain and recover the system. Needs to be on the root partition itself. |
| Server data (data for services provided by system). |
| In someLinux distributions, contains asysfs virtualfilesystem, containing information related to hardware and the operating system. On BSD systems, commonly asymlink to the kernel sources in/usr/src/sys. |
| A place for temporary files not expected to survive a reboot. Many systems clear this directory upon startup or usetmpfs to implement it. |
| The Unixkernel in Research Unix andSystem V.[14] With the addition ofvirtual memory support to3BSD, this got renamed/vmunix. |
| In the earliest versions of Unix,/usr was the directory holding user home directories; the directory name reflected that.[15] By the Third Edition ofResearch Unix, ca. 1973, the operating system's programs overflowed the 256K fixed-head drive containing/bin, so a/usr/bin directory was created on the disk containing/usr to hold some commands; commands and user home directories both resided on/usr.[17] Additional directories, such as/usr/lib and/usr/tmp, were also created under/usr; it now holds executables, libraries, and shared resources that are not system critical, such as theX Window System,window managers,scripting languages, etc. In older Unix systems, user home directories might still appear in/usr alongside directories containing those items; some systems have moved user home directories under a directory other than/usr. |
| Stores the development headers used throughout the system.Header files are mostly used by the#include directive inC language, which historically is how the name of this directory was chosen. |
| Stores the needed libraries and data files for programs stored within/usr or elsewhere. |
| Holds programs meant to be executed by other programs rather than by users directly. E.g., theSendmail executable may be found in this directory.[18] Not present in the FHS until 2011;[19] Linux distributions have traditionally moved the contents of this directory into/usr/lib, where they also resided in 4.3BSD. |
| Resembles/usr in structure, but its subdirectories are used for additions not part of the operating system distribution, such as custom programs or files from aBSDPorts collection. Usually has subdirectories such as/usr/local/lib or/usr/local/bin. |
| Architecture-independent program data. On Linux and modern BSD derivatives, this directory has subdirectories such asman formanpages, that used to appear directly under/usr in older versions. |
| Stands forvariable. A place for files that might change frequently - especially in size, for example e-mail sent to users on the system, or process-IDlock files. |
| Contains system log files. |
| The place where all incoming mail is stored. Users (other thanroot) can access their own mail only. Often, this directory is asymbolic link to/var/spool/mail. |
| Spool directory. Contains print jobs, mail spools and other queued tasks. |
| The place where the uncompiled source code of some programs is. |
| The/var/tmp directory is a place for temporary files which should be preserved between system reboots. |
stat(2) – Linux Programmer'sManual – System Calls from Manned.orghier(7) – Version 7 Unix Programmer'sManualhier(7) – FreeBSD Miscellaneous InformationManualhier(7) – OpenBSD Miscellaneous InformationManualhier(7) – Linux Programmer'sManual – Overview, Conventions and Miscellanea from Manned.org