I've been using this thing called linux since around when I was still in university.

But there's always this question that lingers in my mind long enough that I decided to spill it here.

What's the difference between many libs in linux system? (/lib, /usr/lib, /var/lib, /usr/share/lib etc etc).

I know it's handled automatically by synaptic whenever I install an application, but in case I want to be a linux developer, I sure need to know where to put my application libs in the system.

-- ando

link|improve this question

feedback

2 Answers

up vote 5 down vote accepted

Typically, your software will be installed either under /, or /usr, or /usr/local. This is called the "prefix". / is typically reserved for the most critical operating system programs. /usr/ is reserved for use by package managers. Therefore, when you write software, it is most polite to set it up so that the prefix will be /usr/local. Then this can be overridden when someone packages it for a distribution.

Notice I'm not specifically talking about "lib". There are several common subdirs under the prefix, lib being just one of them. "bin" is used for executables, "share" for data files, "lib" for shared libraries and so on. So if your program is a library, you can install it by default to /usr/local/lib. If it's a normal program, you can have it install to /usr/local/bin with your data files in /usr/local/share. The important thing is that you make it so the prefix is selectable at compile time. Some may prefer to install to /usr rather than /usr/local or vice-versa.

link|improve this answer
So your point is that the locations is rather a guideline than a hard limit? – andreas Nov 18 '09 at 3:52
It's a guideline, but it SHOULD be followed, and many applications expect certain files in certain places. – Jim Deville Nov 18 '09 at 6:35
@james point taken :D – andreas Nov 18 '09 at 8:40
feedback

There is also a standard that describes linux/unix filesystem hierarchy. It can be found at: http://www.pathname.com/fhs/. This is meant mainly for distribution developers, but I don't see any reason who a user/developer should not be aware of it.

link|improve this answer
that was useful, thanks! – andreas Nov 18 '09 at 8:41
feedback

Your Answer

 
or
required, but never shown

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