Debian – Why does software install itself in /usr/lib

debianfhs

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,

Eric.

Best Answer

The real key to understanding the Filesystem Heirarchy Standard is knowing that it is designed with network filesystems in mind.

For every machine of the same OS, release, and architecture, you can share /usr via NFS and mount it.
/usr is (re)mounted after the network stack is initialized.

/var <-- local, r/w optimized
/usr <-- can be mounted over network, possibly even read-only!
/opt <-- local, read mostly
/etc <-- local, read mostly
/srv <-- local, r/w optimized

/home <-- either/or