Filesystem Hierarchy Standard Explained

Filesystem Hierarchy Standard
Status:Published
Version:3.0
Organization:Linux Foundation
Abbreviation:FHS
Domain:Directory structure
Website:

The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of Unix-like systems. It has been made popular by its use in Linux distributions, but it is used by other Unix-like systems as well.[1] It is maintained by the Linux Foundation. The latest version is 3.0, released on 3 June 2015.[2]

Directory structure

In the FHS, all files and directories appear under the root directory /, even if they are stored on different physical or virtual devices. Some of these directories only exist in a particular system if certain subsystems, such as the X Window System, are installed.

Most of these directories exist in all Unix-like operating systems and are generally used in much the same way; however, the descriptions here are those used specifically for the FHS and are not considered authoritative for platforms other than Linux.

DirectoryDescription
/Primary hierarchy root and root directory of the entire file system hierarchy.
/binEssential command binaries that need to be available in single-user mode, including to bring up the system or repair it,[3] for all users (e.g., cat, ls, cp).
[[/boot]]Boot loader files (e.g., kernels, initrd).
[[/dev]]Device files (e.g., [[Null device|/dev/null]], /dev/disk0, /dev/sda1, /dev/tty, [[%2Fdev%2Frandom]]).
/etcHost-specific system-wide configuration files.
There has been controversy over the meaning of the name itself. In early versions of the UNIX Implementation Document from Bell Labs, /etc is referred to as the etcetera directory,[4] as this directory historically held everything that did not belong elsewhere (however, the FHS restricts /etc to static configuration files and may not contain binaries).[5] Since the publication of early documentation, the directory name has been re-explained in various ways. Recent interpretations include backronyms such as "Editable Text Configuration" or "Extended Tool Chest".[6]
/etc/optConfiguration files for add-on packages stored in /opt.
/etc/sgmlConfiguration files, such as catalogs, for software that processes SGML.
/etc/X11Configuration files for the X Window System, version 11.
/etc/xmlConfiguration files, such as catalogs, for software that processes XML.
/homeUsers' home directories, containing saved files, personal settings, etc.
/libLibraries essential for the binaries in /bin and /sbin.
/lib<qual>Alternate format essential libraries. These are typically used on systems that support more than one executable code format, such as systems supporting 32-bit and 64-bit versions of an instruction set. Such directories are optional, but if they exist, they have some requirements.
/mediaMount points for removable media such as CD-ROMs (appeared in FHS-2.3 in 2004).
/mntTemporarily mounted filesystems.
/optAdd-on application software packages.[7]
[[/proc]]Virtual filesystem providing process and kernel information as files. In Linux, corresponds to a procfs mount. Generally, automatically generated and populated by the system, on the fly.
/rootHome directory for the root user.
/runRun-time variable data: Information about the running system since last boot, e.g., currently logged-in users and running daemons. Files under this directory must be either removed or truncated at the beginning of the boot process, but this is not necessary on systems that provide this directory as a temporary filesystem (tmpfs) (appeared in FHS-3.0 in 2015).
/sbinEssential system binaries (e.g., fsck, init, route).
/srvSite-specific data served by this system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems (appeared in FHS-2.3 in 2004).
/sysContains information about devices, drivers, and some kernel features.[8]
/tmpDirectory for temporary files (see also /var/tmp). Often not preserved between system reboots and may be severely size-restricted.
/usrSecondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications. Should be shareable and read-only.[9] [10]
/usr/binNon-essential command binaries (not needed in single-user mode); for all users.
/usr/includeStandard include files.
/usr/libLibraries for the binaries in /usr/bin and /usr/sbin.
/usr/libexecBinaries run by other programs that are not intended to be executed directly by users or shell scripts (optional).
/usr/lib<qual>Alternative-format libraries (e.g., /usr/lib32 for 32-bit libraries on a 64-bit machine (optional)).
/usr/localTertiary hierarchy for local data, specific to this host. Typically has further subdirectories (e.g., bin, lib, share).[11]
/usr/sbinNon-essential system binaries (e.g., daemons for various network services).
/usr/shareArchitecture-independent (shared) data.
/usr/srcSource code (e.g., the kernel source code with its header files).
/usr/X11R6X Window System, Version 11, Release 6 (up to FHS-2.3, optional).
/varVariable files: files whose content is expected to continually change during normal operation of the system, such as logs, spool files, and temporary e-mail files.
/var/cacheApplication cache data. Such data are locally generated as a result of time-consuming I/O or calculation. The application must be able to regenerate or restore the data. The cached files can be deleted without loss of data.
/var/libState information. Persistent data modified by programs as they run (e.g., databases, packaging system metadata, etc.).
/var/lockLock files. Files keeping track of resources currently in use.
/var/logLog files. Various logs.
/var/mailMailbox files. In some distributions, these files may be located in the deprecated /var/spool/mail.
/var/optVariable data from add-on packages that are stored in /opt.
/var/runRun-time variable data. This directory contains system information data describing the system since it was booted.[12]
In FHS 3.0, /var/run is replaced by /run; a system should either continue to provide a /var/run directory or provide a symbolic link from /var/run to /run for backwards compatibility.[13]
/var/spoolSpool for tasks waiting to be processed (e.g., print queues and outgoing mail queue).
/var/spool/mailDeprecated location for users' mailboxes.[14]
/var/tmpTemporary files to be preserved between reboots.

FHS compliance

Most Linux distributions follow the Filesystem Hierarchy Standard and declare it their own policy to maintain FHS compliance.[15] [16] [17] [18] GoboLinux[19] and NixOS[20] provide examples of intentionally non-compliant filesystem implementations.

Some distributions generally follow the standard but deviate from it in some areas. The FHS is a "trailing standard", and so documents common practices at a point in time. Of course, times change, and distribution goals and needs call for experimentation. Some common deviations include:

Modern Linux distributions include a /run directory as a temporary filesystem (tmpfs), which stores volatile runtime data, following the FHS version 3.0. According to the FHS version 2.3, such data were stored in /var/run, but this was a problem in some cases because this directory is not always available at early boot. As a result, these programs have had to resort to trickery, such as using /dev/.udev, /dev/.mdadm, /dev/.systemd or /dev/.mount directories, even though the device directory is not intended for such data.[25] Among other advantages, this makes the system easier to use normally with the root filesystem mounted read-only.For example, below are the changes Debian made in its 2013 Wheezy release:[26]

History

The name of usr

/usr originally stood for "user".[27] This was an artifact of early Unix programming. Specifically, when Ken Thompson and Dennis Ritchie were migrating Unix to a PDP-11, the /bin, /lib... directories, which were to be the first directories to be mounted on startup, and must contain all essentials for the OS to function, became bigger than the RK05 disk drive. So they put some of those in the first RK05, including those that are required for loading the second RK05 drive. The rest were put into the /usr directory.[28] When they got a third drive, users' files were moved to a new directory named /home.[29]

FHS was created as the FSSTND (short for "Filesystem Standard"[30]), largely based on similar standards for other Unix-like operating systems. Notable examples are these: the description of file system layout,[31] which has existed since the release of Version 7 Unix (in 1979); the SunOS [32] and its successor, the Solaris .[33] [34]

Release history

VersionRelease dateNotes
1994-02-14FSSTND[35]
1994-10-09FSSTND[36]
1995-03-28FSSTND[37]
1997-10-26FHS 2.0 is the direct successor for FSSTND 1.2. Name of the standard was changed to Filesystem Hierarchy Standard.[38] [39] [40]
2000-04-12FHS[41] [42] [43]
2001-05-23FHS[44]
2004-01-29FHS[45]
2015-05-18FHS[46]

See also

External links

Notes and References

  1. Web site: FHS. The Linux Foundation Wiki. 2022-01-04.
  2. Web site: lsb:fhs-30 [Wiki] ]. 2023-02-22 . wiki.linuxfoundation.org.
  3. Web site: hier(7) - Linux manual page. 2021-01-06. man7.org.
  4. Book: J. DeFelicc . Preliminary Release of UNIX Implementation Document . 1972-03-17 . IMO.1-1 . E.0 . 8 . D . 6 June 2024.
  5. Web site: /etc : Host-specific system configuration . Filesystem Hierarchy Standard 2.3. 18 February 2016.
  6. http://ask.slashdot.org/article.pl?sid=07/03/03/028258 Define - /etc?
  7. Web site: /opt : Add-on application software packages . Filesystem Hierarchy Standard 2.3 . 18 February 2016.
  8. Web site: /sys : Kernel and system information virtual filesystem . Filesystem Hierarchy Standard 3.0 . 4 June 2017.
  9. Web site: Chapter 4. The /usr Hierarchy. Filesystem Hierarchy Standard 2.3.
  10. Web site: Chapter 4. The /usr Hierarchy, Section 4.1 Purpose. Filesystem Hierarchy Standard 3.0.
  11. Historically and strictly according to the standard, /usr/local is for data that must be stored on the local host (as opposed to /usr, which may be mounted across a network). Most of the time /usr/local is used for installing software/data that are not part of the standard operating system distribution (in such case, /usr would only contain software/data that are part of the standard operating system distribution). It is possible that the FHS standard may in the future be changed to reflect this de facto convention.
  12. Web site: /var/run : Run-time variable data . Filesystem Hierarchy Standard 2.3.
  13. Web site: 5.13. /var/run : Run-time variable data . Filesystem Hierarchy Standard 3.0.
  14. Web site: File System Standard . Linux Foundation . 5.11.1.
  15. [Red Hat]
  16. [SuSE Linux]
  17. [Debian]
  18. [Ubuntu]
  19. Web site: The Unix tree rethought: an introduction to GoboLinux . Hisham Muhammad . 9 May 2003 . 2016-10-04.
  20. Dolstra . E. . Löh . A. . NixOS: A Purely Functional Linux Distribution . http://www.icfpconference.org/icfp2008/ . ICFP 2008: 13th ACM SIGPLAN International Conference on Functional Programming . 367–378 . Victoria, British Columbia, Canada . September 2008.
  21. Web site: 5.3 About the /sys Virtual File System . docs.oracle.com . Oracle . 8 July 2016 . https://web.archive.org/web/20160708193213/https://docs.oracle.com/cd/E37670_01/E41138/html/ol_sysfs.html . 8 July 2016.
  22. Book: Lehey . Greg . The Complete FreeBSD: Documentation from the Source . May 2003 . O'Reilly Media, Incorporated . 9780596005160 . 188, 609 . Fourth .
  23. Web site: Allan McRae . Arch Linux – News: The /lib directory becomes a symlink . archlinux.org . 14 December 2019 . https://web.archive.org/web/20140909234433/https://www.archlinux.org/news/the-lib-directory-becomes-a-symlink/ . 9 September 2014 . live.
  24. Web site: Allan McRae . Arch Linux – News: Binaries move to /usr/bin requiring update intervention . archlinux.org . 15 December 2019 . https://web.archive.org/web/20140910093202/https://www.archlinux.org/news/binaries-move-to-usrbin-requiring-update-intervention/ . 10 September 2014 . live.
  25. What's this /run directory doing on my system and where does it come from? . Lennart Poettering . 30 March 2011 . devel@lists.fedoraproject.org.
  26. Web site: ReleaseGoalsRunDirectory . Debian Wiki.
  27. Web site: /usr . 2023-12-10 . tldp.org.
  28. Web site: Doug McIlroy . M. D. McIlroy . 1987 . A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 . CSTR 139 . Bell Labs.
  29. Understanding the bin, sbin, usr/bin, usr/sbin split . busybox . Rob . Landley . December 9, 2010.
  30. Web site: FSSTND FAQ page . 2016-05-10.
  31. .
  32. http://www.freebsd.org/cgi/man.cgi?query=filesystem&manpath=SunOS+4.1.3 SunOS 4.1.3 manual page for filesystem(7)
  33. .
  34. Web site: filesystem man page – Solaris 10 11/06 Man Pages . https://archive.today/20070704090908/http://manpages.unixforum.co.uk/man-pages/unix/solaris-10-11_06/5/filesystem-man-page.html . dead . 2007-07-04 . 2011-10-15 .
  35. Web site: Index of /pub/Linux/docs/fsstnd/old/fsstnd-1.0/ . Ibiblio.org . 2012-10-16.
  36. Web site: Index of /pub/Linux/docs/fsstnd/old/fsstnd-1.1/ . Ibiblio.org . 2012-10-16.
  37. Web site: Index of /pub/Linux/docs/fsstnd/old/ . Ibiblio.org . 2012-10-16.
  38. Web site: FHS 2.0 Announcement . Pathname.com . 2012-10-16.
  39. .
  40. Web site: Index of /pub/Linux/docs/fsstnd/ . Ibiblio.org . 2012-10-16.
  41. Web site: FHS 2.1 Announcement . Pathname.com . 2012-10-16.
  42. Web site: FHS 2.1 is released . Lists.debian.org . 2000-04-13 . 2012-10-16.
  43. Web site: Filesystem Hierarchy Standard – Version 2.1, Filesystem Hierarchy Standard Group . Daniel . Quinlan . Acadia Linux Tutorials . . Wolfville, Nova Scotia, Canada . 12 April 2000 . 18 October 2012 . https://web.archive.org/web/20120327075156/http://cs.acadiau.ca/~jdiamond/Acadia-Linux-template-tutorial/resources/fhs-2.1.pdf . 27 March 2012.
  44. Web site: Filesystem Hierarchy Standard – Version 2.2 final Filesystem Hierarchy Standard Group . Rusty . Russell . Rusty Russell . Daniel . Quinlan . Filesystem Hierarchy Standard . 23 May 2001 . 18 February 2016 .
  45. Web site: Filesystem Hierarchy Standard - Filesystem Hierarchy Standard Group . Rusty . Russell . Rusty Russell . Daniel . Quinlan . Christopher . Yeoh . 28 January 2004 . 2014-11-29.
  46. Web site: Filesystem Hierarchy Standard . Christopher . Yeoh . Rusty . Russell . Daniel . Quinlan . . 19 March 2015 . 2015-05-20.