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.

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

share|improve this question
add comment

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

share|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
add comment

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.

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

/bin and /sbin

  • binaries used for system administration and also in single usermode. Their library files are located in /lib.

/usr/bin and /usr/sbin

  • contain non essential non essential binaries used by all user and binaries used for network services and all.Their libraries are placed in /usr/lib.

/var/lib

  • contain files which preserve information about state of running programs or instances of programs .user neednt change this.

/usr/share/lib

  • Contains architecture-independent data files.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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