What is the intended purpose of top-level linux/unix directories and what should they contain? [duplicate]

Possible Duplicate:
Linux file system

As the title says, what is the intended purpose of top-level linux/unix directories and what should they contain? What is the meaning of their names? e.g. /var /etc /opt /usr

Is there a definitive guide that applies to all flavours/flavors/releases/distributions of Unix and Linux?

It seems to me to be arbitrary as to what the purpose of these directory/folders are and what should go in them.

What did the developers/creators of Unix and Linux variants have in mind for the design and naming?

The reason why I ask is not academic discussion but for better understanding of the system to promote:

  • more efficient, cleaner, precise, repeatable maintenance and enhancements
  • faster more efficient troubleshooting of problems
  • faster more efficient management of installations
  • locate certain files faster
  • write platform/distribution independent applications that install in the correct locations that can, for example run on any Linux distribution

I would also like answers for the sub-directories of these, e.g. /usr/lib /usr/local/ /var/lib etc... please.

I know that there are other factors that can influence the above items but am just looking for answers to my question here.

Thanks in advance.


What you're looking for is the Filesystem Hierarchy Standard. Answers to all the questions you ask are covered in the FHS.

With regard to writing applications that conform to any Linux distribution, you may also want to look at the XDG Base Directory Specification. It is more desktop/user oriented.


The Filesystem Hierarchy Standard is probably the best reference here (see Wikipedia's entry and the full text in various formats), as recommended by the LSB. Though no distribution that I know of completely fits the standard, most are close so it is a good reference for deciding your own "best practise".