3

I'd like to place a handmade script in its conventional place and folder structure. It's currently located in /opt/chkobm/chkobm, but it seems like a bad practice since it requires $PATH to include wildcard paths (/opt/*/)

From TLDP (section "Linux Filesystem Hierarchy"):

Programs to be invoked by users are located in the directory /opt/'package'/bin.

Firstly, is there a consensual rule about where to place such files ? (/usr/bin looks to me like a viable alternative place) Secondly, should I place handmade scripts to /opt/*/bin/ and export this path to $PATH ?

7
  • 5
    I always thought that the correct place for homebrew is /usr/local/ as no package system writes there. Most of the default configs also brings /usr/local/bin added to the path
    – theist
    Aug 27, 2020 at 8:08
  • Indeed, TLDP corroborates your point (Section "1.17 /usr"). Thanks for helping me distinguish those folders !
    – Sumak
    Aug 27, 2020 at 9:24
  • 1
    @theist /usr/local is using the same bad semantics as /usr did use in 1975. This is why /usr/local has been abandoned by UNIX manufacturers in 1988.
    – schily
    Aug 27, 2020 at 9:43
  • 2
    @schily How is /usr/local bad semantics? It's perfect for saying "this is something you can't get from a package manager" "this is something we wrote for this specific server" or "this is safe from being overwritten during an upgrade"
    – Stewart
    Aug 27, 2020 at 11:17
  • 2
    Does this answer your question? How should executables installed under /opt be added to the path?
    – dank8
    May 8 at 5:44

1 Answer 1

0

/usr/local/bin is the idiomatic place to put this.

Per the Linux filesystem heirarchy:

The original idea behind /usr/local was to have a separate ('local') /usr directory on every machine besides /usr, which might be just mounted read-only from somewhere else. It copies the structure of /usr. These days, /usr/local is widely regarded as a good place in which to keep self-compiled or third-party programs. 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. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr. Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

I tend to rely on the FHS as defined be Debian. Debian is pretty good at enforcing the standards. This is what they have to say about opt:

The directories /opt/bin, /opt/doc, /opt/include, /opt/info, /opt/lib, and /opt/man are reserved for local system administrator use. Packages may provide "front-end" files intended to be placed in (by linking or copying) these reserved directories by the local system administrator, but must function normally in the absence of these reserved directories.

...

Generally, all data required to support a package on a system must be present within /opt/, including files intended to be copied into /etc/opt/ and /var/opt/ as well as reserved directories in /opt.

...

The structure of the directories below /opt/ is left up to the packager of the software, though it is recommended that packages are installed in /opt// and follow a similar structure to the guidelines for /opt/. A valid reason for diverging from this structure is for support packages which may have files installed in /opt//lib or /opt//bin.

Debian's definition of /usr/local is identical to the previous definition from the TLDP link.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .