Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
Google Chrome opts to use that directory for some reason. –  Camilo Martin Jul 11 at 2:30
    
@CamiloMartin I guess it's optional. –  becko Aug 19 at 18:57
    
@becko Well, it must be an optimal choice if Google ad opted it. –  Camilo Martin Aug 19 at 19:46

3 Answers 3

up vote 26 down vote accepted

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

share|improve this answer
    
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
    
The answer is yes. –  Egil Apr 14 '11 at 6:24

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?

share|improve this answer
    
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
    
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. –  Camilo Martin Jul 11 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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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