December 30, 2019
To introduce readers to the UNIX Filesystem Hierarchy Standard.
If you’ve worked in a Unix environment, you’ve worked with directories such as:
/etc, /tmp, /opt, /var, /usr, /dev, /bin, /sbin.
But have you ever wondered why these exist and what the differences between them are? Well, after a some years I finally researched and came across the UNIX Filesystem Hierarchy Standard.
I’ve abridged the contents of the spec, and would encourage anyone to read the original for a more in-depth look
/bin: Essential user command binaries (for use by all users)/dev: Device files/opt: Add-on application software packages/etc: Host-specific system configuration/root: Home directory for the root user (optional)/home: User home directories (optional)/sbin: System binaries/tmp: Temporary files/srv: Data for services provided by this system/lib: Essential shared libraries and kernel modules/media: Mount point for removable media/mnt: Mount point for a temporarily mounted filesystem/usr hierarchy
/usris the second major section of the filesystem./usris shareable, read-only data. That means that/usrshould be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere.
/usr/bin: Most user commands/usr/include: Directory for standard include files./usr/lib: Libraries for programming and packages/usr/libexec: Binaries run by other programs (optional)/usr/local/share : Local architecture-independent hierarchy/usr/sbin : Non-essential standard system binaries/usr/share : Architecture-independent data/var hierarchy
/varcontains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
/varis specified here in order to make it possible to mount/usrread-only. Everything that once went into/usrthat is written to during system operation (as opposed to installation and software maintenance) must be in/var.If
/varcannot be made a separate partition, it is often preferable to move/varout of the root partition and into the/usrpartition. (This is sometimes done to reduce the size of the root partition or when space runs low in the root partition.) However, /var must not be linked to/usrbecause this makes separation of/usrand/varmore difficult and is likely to create a naming conflict. Instead, link/varto/usr/var.
I'm Patrick El-Hage and I live and work in San Francisco. I'm also on Twitter.