Difference between /opt/bin and /opt/X/bin directories

directory-structurefhspackage-management

The /opt/ directory in Linux is used for installing add on packages.

What is the difference between the /opt/<package>/bin directory and the /opt/<package>/X/bin directory? What is the difference between placing the binary in these directories?

Could you also please point me to some documentation which explains what the directory structure should be for a new software package/application installed in the /opt/ directory?

Best Answer

Per FHS, /opt/bin, /opt/lib, /opt/info, /opt/include, /opt/doc, and /opt/man are there for the administrator's convenience. For instance, you might have /opt/jdk and /opt/LibreOffice holding your jdk and office suite, but rather than add a new element to $PATH, ld.so.conf, etc. every time you add another package, you can just symlink the binaries to /opt/bin, the libs to /opt/lib, etc.

Basically, you should put the binary in /opt/foo/bin and, at your discretion, symlink the binary into /opt/bin

FHS does not specify any particular organization within /opt/package, but the widely accepted practice is to make a bin and lib directory, and possibly doc, man, etc. as needed.

As a side note: if you are writing to /opt/foo FHS also clears you to write to /etc/opt/foo and /var/opt/foo.

Related Question