How should executables installed under /opt be added to the path?

13,725

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.

Share:
13,725

Related videos on Youtube

Kenneth Hanson
Author by

Kenneth Hanson

Updated on September 18, 2022

Comments

  • Kenneth Hanson
    Kenneth Hanson over 1 year

    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?

  • Kenneth Hanson
    Kenneth Hanson over 8 years
    Okay, so it sounds like this is more an issue of standard convention than anything else. I was a bit weirded out by the lack of symmetry "There is a difference between /opt and /usr/local/bin" as opposed to than "...between /opt and /usr/local" or "...between /opt/bin and /usr/local/bin", but after getting to the end I suspect it was meant as a way to combine /opt/bin and /opt/.../bin. If so, I wonder if the wording could be improved.
  • vic
    vic about 8 years
    @chaos You write that, according to FHS, /opt/package/bin/ or at least /opt/bin/ should be added to $PATH. I read through the posted reference and it does say a lot about how to structure /optand what to have inside there but I could not find a confirmation that any of those directories under /opt should be added to $PATH. Could you maybe elaborate how you came to that conclusion? Cheers
  • Kenneth Hanson
    Kenneth Hanson over 6 years
    @vic The same reason you would put any other /whatever/bin directory to $PATH -- so you can invoke the executables without typing the full path every time.
  • Didier A.
    Didier A. over 4 years
    @KennethHanson Nah, I kind of agree with vic, the way FHS is worded, it seems that the intended behavior is to add /opt/bin to the path, and symlink the /opt/package/bin to it.
  • Kenneth Hanson
    Kenneth Hanson over 4 years
    @DidierA. Maybe I was misreading vic, but it sounded like he was questioning whether anything should be added to $PATH at all. The FHS says basically nothing about $PATH in general (you can ctrl-F to see), so I wouldn't try too hard to divine the authors' assumptions. Strictly speaking, they are separate issues. That said, I agree that adding just /opt/bin seems to be the most sensible default choice.
  • Didier A.
    Didier A. over 4 years
    @KennethHanson Ya, fair enough. I guess they do mention that /opt/bin can be used for " Packages may provide "front-end" files intended to be placed in (by linking or copying) these reserved directories by the local system administrator". Which sounds to me like they imply that /opt/bin is only to be used for that purpose. But obviously, you can also add each /opt/package/bin to your path if you prefer.