Why does software install itself in /usr/lib?

Eric MORAND asked:

I have been using Linux servers for years now and I keep on being confused by the Filesystem Hierarchy Standard. Usually, I can live with the confusion. But now that I am developing my own software for Linux, I need to understand where it is supposed to be installed by package managers.

I was pretty convinced that /opt was the perfect location for my application. But after having investigate my Debian filesystem, I’m not sure anymore : a lot of softwares are actually installed in /usr/lib ! To name a few : MySQL, MySQLWorkbench, Nautilus, Rythmbox…

According to the FHS, /usr/lib is supposed to contain “Libraries for programming and packages” and “includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts” (See here).

A lot of softwares located in /usr/lib of my debian server are not libraries or internal binaries but full-fledged user executable softwares !

I’m still on track to have my application installed in /opt. But I really would like to understand if this is correct and, above all, why.

Thanks by advance for your kind advices,


My answer:

The difference is that /usr is meant to hold packages installed as part of the system. Packages you get from the Debian/Ubuntu repositories, PPAs, etc., go here. While /opt is meant for unbundled third party applications that are not distributed through the distribution’s package distribution process.

If you distribute .deb or .rpm packages, with an eye toward eventually getting your software included in the official repositories, you should install to /usr. Otherwise install to /opt. In either case, your application should be able to be compiled to run in any arbitrary location (e.g. with the help of the GNU autotools).

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.