Introduction

This article was suggested by Wayne Snyder (instructor Oxnard College, CA - CNIT 143 Linux Essentials).

The “File Hierarchy Standard”1 (FHS) was originally created in 1994 to provide consistency amongst various Unix systems. The latest version (v3.0 March 19, 2015) has been broadened as a guide for other families of *Nix systems, including POSIX2, Linux3, MacOSX4, etc.

Its main purpose is to provide a “convention over configuration”5 approach to filesystem organization that tries to standardize the location of directories and files so that software systems, programmers and users know where to find what they need.

The scope of this article is a simplified high-level overview of the top level directory structure and the purpose of each directory. The the various bin directories will be given special focus.

Directory Structure

Here is an real world example of the FHS used by Debian6 a Linux3 based system.

/          - root directory of the overall filesystem
├── bin    - binaries: this is where standard executables are stored
├── boot   - files for booting the system
├── dev    - devices: runtime files descriptors for devices
├── etc    - system level config files for services and applications
├── home   - user accounts
├── lib    - system libraries,kernel modules,device drivers
├── media  - mount: removeable media, USB drives, CD-ROMs, DVDs
├── mnt    - mount: temporary filesystems - ext4, hpfs, nfs, ntfs, smb
├── opt    - optional: software that is not normally used by the system
├── proc   - processes, system information
├── root   - root user account
├── sbin   - binaries: this is where standard executables are store
├── sys    - system: interface to the system kernel
├── tmp    - temporaries: transient information that may be deleted
├── usr    - used to be the user directory - see next section 
└── var    - variables: log files, caches, dynamic libraries 

Focus on Various /bin Directories

There is a lot of confusion about the various /bin7 directories.

Way back when Unix was being developed their root filesystem outgrew their 0.5 MB system disk. They decided to move some of the binaries to the larger but slower RK05 disk pack. This is where all the user and home directories lived and why the mount was called /usr.

They replicated the system directories onto the RK05 disk (/bin, /sbin, /lib, /tmp) and wrote files to those new directories because their original disk was out of space.

So now they had this arrangement

  • /bin
    Executable programs which are needed in single user mode and to bring the system up or repair it.
  • /sbin
    Similar to /bin it holds commands needed to boot the system, but not usually executed by normal users.
  • /usr
    Usually mounted from a separate partition. Holds only sharable, read-only data. Can be mounted by various machines running Linux.
  • /usr/bin
    Primary directory for executable programs. Most programs executed by normal users not needed for booting or for repairing the system and which are not installed locally should be placed in this directory.
  • /usr/sbin
    Program binaries for administration - not essential for the boot, mounting /usr, or for system repair.

References

  • Also information from $ man hier page.
  1. “Filesystem Hierarchy Standard” Linux Foundation Referenced Specifications, The Linux Foundation, March 19, 2015, https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html 

  2. POSIX IEEE standard, https://standards.ieee.org/search-results.html?q=posix 

  3. Linux, https://www.linux.com/what-is-linux/  2

  4. MacOSX, https://www.apple.com/ 

  5. “Convention over Configuration” 

  6. Sampled from a typical Debian system, https://www.debian.org/ 

  7. Geniar, Mattias. “Understanding the /Bin, /Sbin, /Usr/Bin and /Usr/Sbin Split.” Mattias Geniar, https://www.facebook.com/www.ma.ttias.be/, 16 May 2015, https://ma.ttias.be/understanding-the-bin-sbin-usr-bin-and-usr-sbin-split/