84

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

Niroshan
  • 1,178

3 Answers3

92

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

Egil
  • 14,522
14

I would install third-party binary-only packages to /opt.

Anything you build yourself from source I would put in /usr/local.

netbeans is in the Ubuntu Repos. Do you need a specific version?

Broam
  • 1,151
12

It's all about packaging. If something is packaged in the LHS way (putting executables into bin/ libraries into lib/ etc.) it should go into /usr/local.

If something has a top level directory and doesn't follow that model, it goes in /opt. Generally, you have to explicitly add stuff in /opt to your PATH.

See also This question on superuser

TREE
  • 296