Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by quack quixote, Diago Jan 4 '10 at 13:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
duplicate (original includes pretty pictures in the answers): superuser.com/questions/548/linux-file-system –  quack quixote Jan 4 '10 at 10:26
    
Thanks ~quack the diagrams are great. I hope I have helped others by asking the same question in a different way to help their search. Up-voted your comment. –  therobyouknow Jan 4 '10 at 17:08
    
so I would hope we could keep this question for that reason and not remove it. Up-voted your comment. Thanks. –  therobyouknow Jan 4 '10 at 17:18

3 Answers 3

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks. Up-voted your comment. Thanks also for the XDG item - this answers more of my question. –  therobyouknow Jan 4 '10 at 17:12
    
I'm accepting this as the answer as it mentions advice ("XDG") about how to write applications for any Linux distribution. But I should say, all answers here are great and of help and thanks for the rapid response. I'm grateful to ~quack for mentioning the friendly diagram in the comment below the question ( superuser.com/questions/548/linux-file-system –  therobyouknow Jan 4 '10 at 17:14

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".

share|improve this answer
    
Thanks. Up-voted your answer. –  therobyouknow Jan 4 '10 at 17:11

There is a standard structure called Filesystems Hierarchy Standard (FHS). Some linux dists adhere to it, some don't.

In simple terms, when it comes to /usr and /var, you can say that /usr are user installed files that don't change and /var are for files that do change(spool, formatted documentation). This is so you can , for example, mount /usr over a network and have several computers that share the "static" /usr/ and have a local /var for files that are "dynamic".

Quotes from Linux System Administrators Guide: http://tldp.org/LDP/sag/html/dir-tree-overview.html

/usr/lib

Unchanging data files for programs and subsystems, including some site-wide configuration files. The name lib comes from library; originally libraries of programming subroutines were stored in /usr/lib.

/usr/local

The place for locally installed software and other files. Distributions may not install anything in here. It is reserved solely for the use of the local administrator. This way he can be absolutely certain that no updates or upgrades to his distribution will overwrite any extra software he has installed locally.

/var/lib

Files that change while the system is running normally.

You can read more at http://tldp.org/LDP/sag/html/dir-tree-overview.html if there are other directories you want to know about.

share|improve this answer
    
s/user installed filed/user installed files/, s/does'nt/don't/. Could you add a link to the FHS itself? I wouldn't be linking to SAG except for deep background - it was last updated circa 2003, so it's an antique now. –  James Polley Jan 4 '10 at 9:46
    
I agree its antique. However, i think the points it makes and how it describes the directories are valid and descriptive. Thank you for the misspells and grammar pointers. –  artifex Jan 4 '10 at 10:12
    
No problem :) The background from SAG and older guides is definitely interesting - without it you'd never understand why we've ended up with /opt and /srv, for instance - but it's the FHS which gives the quick answers about the current usage. –  James Polley Jan 4 '10 at 10:44
    
Thanks artifex, I've up-voted your answer. –  therobyouknow Jan 4 '10 at 17:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.