Linux / OS Fundamentals Series

🗂️ /etc and the Linux Directory Layout (FHS) from the "Top 1%" Perspective: Why Config Files Live in /etc

Introduction

This article is part of the Top 1% Series’ full article guide. It’s a spin-off from the point in the self-built L2TP/IPsec server hands-on lab where /etc/ipsec.conf is edited.

Prerequisites

Getting the Big Picture

In a nutshell

Linux’s directory layout follows an industry standard called the FHS (Filesystem Hierarchy Standard), and at its backbone are two axes: (a) is this data host-specific, or generic data that can be shared/reused across multiple machines, and (b) is this static data that never changes once installed, or mutable data that gets rewritten during operation. /etc being the standard home for config files isn’t just convention — it’s because, sorted along these axes, it occupies a clear position: “host-specific, mutable data.”

graph TB
    subgraph Axis["The two axes running through the FHS"]
        A["Host-specific vs. shareable"]
        B["Static (immutable) vs. mutable"]
    end
    A --> Etc["/etc<br/>Host-specific, mutable<br/>(config specific to this machine)"]
    B --> Etc
    A --> Usr["/usr<br/>Shareable, static<br/>(the program bodies a package installs)"]
    B --> Usr
    A --> Var["/var<br/>Host-specific, mutable<br/>(logs, caches, DBs — data that grows/shrinks at runtime)"]
    B --> Var

Fundamentals, Thoroughly Explained

The role of each major top-level directory

Sorting the FHS’s top-level directories that come up frequently in practice along the two axes above:

DirectoryRoleHost-specific?Mutable?
/etcSystem-wide config filesHost-specificMutable (hand-edited)
/usrProgram bodies, shared libraries, and docs a package installsShareable (works if copied to another machine)Static (updated via package management)
/bin, /sbinBasic executable commands (on most modern distros, largely symlinks into /usr/bin, /usr/sbin)ShareableStatic
/varLogs, caches, databases — data that grows and shrinks at runtimeHost-specificMutable (auto-generated by programs)
/homeOrdinary users’ personal dataHost-specificMutable
/tmpTemporary files (often cleared on reboot)Host-specificMutable, transient
/optThird-party software packages outside the package manager’s scopeCould be eitherStatic
/rootThe root user’s home directory (kept separate from /home)Host-specificMutable

The act of opening /etc/ipsec.conf in nano and hand-editing it lines up exactly with /etc’s definition: host-specific, mutably edited by a human.

What does `~` (tilde) actually point to?

The ~ you see constantly in the shell is a special symbol meaning “the home directory of whichever user is currently logged in.” At runtime, the shell automatically expands it based on the logged-in username — to /home/<username> for a regular user, or /root for the root user. For example, cd ~ as the regular user ubuntu takes you to /home/ubuntu, while cd ~ after switching to root with sudo su - takes you to /root. Follow it with another username, as in ~user, and it points at that specific user’s home directory instead (~ubuntu always resolves to /home/ubuntu). A path like ~/.ssh/authorized_keys, which comes up constantly in this site’s hands-on labs, means “the .ssh directory under my own home directory” — keep in mind that the actual resolved path changes depending on which user runs the command.

Why is `/bin` a symlink to `/usr/bin` on so many distributions (the usrmerge)?

Historically, the minimal set of commands usable in the very early boot stages — before /usr was even mounted — lived in /bin//sbin, with most other commands in /usr/bin//usr/sbin. But as the initial RAM disk (initramfs) mechanism matured on modern Linux, keeping this split served little practical purpose, so many distributions (Debian/Ubuntu, etc.) adopted the “usrmerge,” turning /bin//sbin into plain symlinks to /usr/bin//usr/sbin to simplify the layout.

The convention of per-service subdirectories

Since /etc would otherwise fill up with a chaotic pile of config files, software with multiple config files follows a convention of grouping them under a subdirectory named after the service, like /etc/xl2tpd/xl2tpd.conf or /etc/ppp/chap-secrets. This isn’t mandated by the FHS down to individual filenames — it’s a practical organizing convention that took hold across the package-developer community. Simple software that only needs one config file tends to sit directly under /etc (like /etc/ipsec.conf), while more complex software involving multiple files, certificates, or keys tends to get grouped into a subdirectory.

What the /etc//usr split actually buys you: an update-resilient design

The practical payoff of this split is that an OS/software update (apt upgrade, etc.) can swap the program bodies under /usr for new versions while leaving the administrator’s hand-tuned config under /etc essentially protected. When a package management system detects that a config file under /etc has been manually edited, it doesn’t blindly overwrite it — it often asks how to reconcile the new default config with the current one (the confirmation prompt dpkg shows on a config-file update is one example of this). This safe update flow only works because the program body (/usr, disposable) and the configuration (/etc, precious) are physically kept in separate directories.

The View from the Top 1% (What Experts See)

How the meaning of /etc and /var shifts in the container/cloud era

In disposable execution environments like Docker containers, this “host-specific, mutable” nature of /etc//var directly informs a design decision: don’t bake them into the container image itself — treat them as something mounted in from outside (bind mounts, volumes). The container image itself is built as a collection of “static, shareable” data, like /usr, while /etc config and /var data get injected at runtime from the host or a volume. This is a generalization of the FHS’s two-axis classification, extended from a single-machine concern into a design principle of container orchestration.

The FHS is “an industry agreement,” not “an enforced standard”

The FHS is a specification maintained by the Linux Foundation, but the kernel itself doesn’t enforce it. In principle, it’s technically possible to put any file in any directory. This layout is followed almost without exception in practice because the major distributions’ package management systems (apt, dnf, etc.) effectively assume that package developers follow the FHS. When building or customizing your own software, following this “industry-wide implicit agreement” lets other administrators and tools operate on your system without confusion.

Common Misconceptions and Pitfalls

Common Sticking Points (Troubleshooting)

  1. A config change you made by hand disappeared or got overwritten after an update: Check whether you missed the package management system’s config-update confirmation prompt (files like dpkg’s .dpkg-new/.dpkg-old). In most cases, the old config is preserved as something like .dpkg-old, not completely lost.
  2. Disk usage under /var spikes and fills the disk: A classic pattern of logs (/var/log) or package caches (/var/cache) bloating. Check the breakdown with du -sh /var/*, and confirm whether logrotate (automatic log rotation, compression, deletion) is actually working.
  3. A file you manually placed disappeared after a package update: Placing your own files inside a package-managed directory (under /usr, etc.) risks losing them on the next update or reinstall. It’s safer to place custom files somewhere outside package management’s reach, like /usr/local or /opt.

Prevention and Long-Term Fixes

Summary

Starting Today

  1. When you can’t find where a new piece of software’s config lives, ask yourself “is this host-specific?” and “does a human edit this?” — it’ll narrow down where under /etc to look.
  2. When placing your own scripts or files, get in the habit of avoiding directories under package management’s control, and use /usr/local or /opt instead.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).