I put a copy of my answer to Quora here.
Unix file system hierarchy is full of historical crap but there are
some principles behind that. This is a division that I have found useful:
- Directories that are absolutely required in the boot (/bin, /lib,
/root) vs. files that are needed only in multi-user mode (/usr,
/home). This was pretty important when you wanted to boot from a diskette.
- Directories that are hardware independent (/usr/share) vs.
directories that are hardware dependent (most). Debian uses this
division to reduce workload in compiling distribution to different
architectures but it also tells what directories can be shared with
other computers of different architectures.
- Directories that should be distro-identical (most) vs. directories
that should be backed up to get machine identically running (/home,
/etc, /usr/local, /opt, /var/www).
- Directories that can be shared as a shared disk with other computers
of the same architecture (*bin, *lib) or even with different
architecture (/home, /root, /var/www), vs. directories that are
strictly local (/etc, /var)
- Directories that have to be writable (/var, /home) vs. directories
that are read-only (*bin, *lib). Additionally there are
configuration directories that can be read-only in a configured
system (/etc, /var/www)
- Additionally, there are directories that are transient, or they are
initialized in every boot of the machine: /tmp, /media, /mnt, /run,
/proc, /dev, /sys
It is not always trivial to say what are the attributes in general.
The most messy directory is /var, but there is a plan to move
/var/www-style directories to /srv and transient directories into /run.
So, what is left is non-transient local data (caches, logs, spools).
/srv is not yet widely used.
One more dimension to understand is that
- bin is a program that is meant to be run by a user in command line
- sbin is a program that is meant to be run by an administrator in
- lib are libraries used by programs
- libexec are programs that are meant to be used only by other programs
The last category has been in one of the others in the different steps
of the history. First they were in lib (like /usr/lib/sendmail is still
there), then in sbin. /usr/libexec is still mostly unused.
Using this division it should be pretty clear what you have in these directories.
I try to put directories to a Venn-diagram (base from Wikimedia).