Linux – How to Add Executables Installed Under /opt to PATH

directory-structurefhslinuxsoftware installationUbuntu

Can programs installed under /opt be safely symlinked into /usr/local/bin, which is already in the PATH by default in Ubuntu and other Linux distros?

Alternatively, is there some reason to create a separate /opt/bin and add that to the PATH, as in this answer: Difference between /opt/bin and /opt/X/bin directories?

Best Answer

There is a difference between /opt and /usr/local/bin. So just symlinking binaries from one to another would be confusing. I would not mix them up.

/opt is for the installation of add-on application software packages, whereas the /usr/local directory is for the system administrator when installing software locally (with make and make install). /usr/local/bin is intended for binaries from software installed under /usr/local.

According to the File Hierarchy Standard, the correct way would be to add /opt/<package>/bin to the $PATH for each individual package. If this is too painful (when you have an uncountable number of /opt/<package>/bin direcories for example) then you (the local administrator) can create symlinks from /opt/<package>/bin to the /opt/bin directory. This can then be added to the users $PATH once.

Related Question