Some programs that I build from source have a directory libexec in the installation directory (for example, gnuplot). As a matter of rule, I add a

export LD_LIBRARY_PATH=${installation directory}lib:${LD_LIBRARY_PATH}

to my .bashrc when I have lib folders. Likewise with PATH and PKG_CONFIG_PATH if ${insdir}/bin and ${insdir}/lib/pkgconfig exist. I have developed this practice based on the many indications to do so gathered with usage.

I can see that the files contained in libexec are binary executables.


What is their purpose in contrast to the executables stowed in bin?

Should dedicated variables (in the guise of PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH) be set to make them known to the shell environment? If not, would PATH would do just as fine? Or perhaps there's no need ever to set anything because they are used by special programs that are content with a relative path?

This topic is close to Portable binaries and the libexec path which addresses a similar point when creating libexec files in a package, though


libexec is intended for private binaries, i.e. binaries which are used by a program but which shouldn't be available generally. See the FHS:

/usr/libexec includes internal binaries that are not intended to be executed directly by users or shell scripts.

So no, you shouldn't add it to any PATH-style variables.

  • 1
    The exception would be cases like homebrew on Macs, which, for packages like coreutils that mask system utilities, keep ls, etc. in .../libexec/gnubin and uses gls, etc. in /usr/local/bin. If you want ls to be GNU ls, then it's easiest to add that folder to PATH. – muru Mar 5 '17 at 13:39
  • @StephenKitt Does this hold also when we are outside /usr? – XavierStuvw Mar 5 '17 at 13:39
  • I would say it still holds, yes, regardless of the prefix, except for very specific cases like muru's example. – Stephen Kitt Mar 5 '17 at 14:09
  • Basically programs which need to use binaries that they install in libexec are supposed to know where they are. – Stephen Kitt Mar 5 '17 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.