/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/local
so 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.
This change was made to enable installing versions of the same library compiled for different architectures (e.g. on an AMD64 system, one version might go in /usr/lib/x86_64-linux-gnu
while the other goes in i386-linux-gnu
).
Both the standard linker and dynamic linker know about these directories, so the change should be invisible for most applications. If the application is searching for actual library files manually, then it will need modification.
Details of the changes to Ubuntu can be found here:
https://wiki.ubuntu.com/MultiarchSpec
Best Answer
Please refer to the Filesystem Hierarchy Standard (FHS) for Linux for this.
/bin
: For binaries usable before the/usr
partition is mounted. This is used for trivial binaries used in the very early boot stage or ones that you need to have available in booting single-user mode. Think of binaries likecat
,ls
, etc./sbin
: Same, but for binaries with superuser (root) privileges required./usr/bin
: Same as first, but for general system-wide binaries./usr/sbin
: Same as above, but for binaries with superuser (root) privileges required.None of the above. You should use
/usr/local/bin
or/usr/local/sbin
for system-wide available scripts. Thelocal
path means it's not managed by the system packages (this is an error for Debian/Ubuntu packages).For user-scoped scripts, use
~/bin
(a personal bin folder in your home directory).The FHS says for
/usr/local
: