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

  • 5
    Google Chrome opts to use that directory for some reason. Jul 11 '14 at 2:30
  • 3
    @CamiloMartin I guess it's optional.
    – becko
    Aug 19 '14 at 18:57
  • 5
    @becko Well, it must be an optimal choice if Google ad opted it. Aug 19 '14 at 19:46
  • 3
    Even if you all where right, opt imus Prime sounds better.
    – m3nda
    Jan 26 '16 at 0:42
  • 3
    Lol..I came late to the party ..But it seems like you people have opt imized the comments section a lot..:P
    – john400
    Sep 2 '17 at 3:36

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

  • 1
    so netbeans goes to /usr/local as it depends on jdk and other compilers + plus it follows linux FHS?
    – Niroshan
    Apr 14 '11 at 4:52
  • 1
    The answer is yes.
    – Egil
    Apr 14 '11 at 6:24
  • 1
    If i want to install conda globally as suggested here, is /opt the right place?
    – Alexey
    Mar 18 '17 at 11:34
  • @Egil, Why doesn't mac have an opt directory?
    – Pacerier
    Nov 1 '17 at 23:12
  • I previously upvoted this answer, but I now see that its conclusions differ slightly from this Linux Journal article. The article implies that with packaged software, it matters who supplied the package. If the package is from the OS's package repo, then it should be installed under /usr (or, presumably, even directly under /bin, /lib, etc) as usual. If, however, it is from another source, then it should be put into /usr/local. That would potentially include the "open source sip-client" .deb in the answer.
    – user13975
    Mar 31 '18 at 2:58

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?

  • Is there any rationale behind it or is it just a good practice? (I mentioned netbeans as an example - I changed that part to remove any ambiguities). Thank you
    – Niroshan
    Apr 13 '11 at 17:27
  • I think other answers have said it best. Usually third-party binaries are self-contained.
    – Broam
    Apr 13 '11 at 21:03
  • 1
    What about things that depend on runtimes, like Python or Java software? I'd put them on /opt but am not sure if it's correct. Jul 11 '14 at 2:33

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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