Ubuntu – Use of /opt and /usr/local directories in the context of a PC


What is the difference between /opt and /usr/local directories and what kind of programs should be installed to them?

I referred to Linux File-system Hierarchy but the explanation is not that clear.
According to above link;

/opt :- This directory is reserved for all the software and add-on packages that are not part of the default installation

/usr/local :- The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated.

In the context of a PC without any networked computers what should be the directory to install a software that will be accessed by multiple local users? (i.e. where should I install a software like netbeans)

Thank you

Best Answer

/opt is for third-party applications that don't rely on any dependencies outside the scope of said package. /usr/local is for packages installed on this machine outside the scope of the distribution package manager.

An example:

An open source sip-client supplied as a .deb would install into /usr. If it was built with the Qt framework, apt would pull it in as a dependency.

The same open source sip-client built from source would reside in /usr/localso it would not be messed up by apt if you later installed a .deb package for the same application. You could either build its dependencies from source, or get them from the package manager.

A third-party application in /opt is supposed to be self-contained. For instance, a proprietary sip-client using Qt would not rely on the version from apt, but would have it bundled or statically linked in.

For more information, take a look at the Filesystem Hierarchy Standard.