Filesystem Hierarchy Standard - Where to put sourceable functions?

I have a few bash scripts running system checks. These scripts source configuration options from a file /etc/healthchecks/config.

Along with the config file, I have a shared functions file. The scripts should be able to source that file and run the functions therein.

Based on the Filesystem Hierarchy Standard, where should I put the shared functions file? It's not a configuration, so it doesn't seem like it belongs in /etc, but it's also not being executed so /usr/bin seems incorrect. Maybe /usr/lib?


You should put your healthchecks executables in /usr/local/bin or in /opt/bin. If you see your folder /opt is empty, means your linux distribution doesn't use it. So, the suitable place would be /usr/local.

/usr/local and /opt are where every "manual" package/program must be placed. /usr is for packages managed by package managers (i.e, dpkg). /opt is the "standard place" for manual packages according to FHS, but debian distros use /usr/local instead.

For configuration files, they must be placed on /usr/local/etc, since /etc is for configuration files of automatic packages and other system programs.

The correct place for your shared functions is then /usr/local/share (/usr/share is for shared files of automatic packages). Every file which is designed to be read-only and independent of the arquitecture belongs to /usr/share or /usr/local/share (if they are own by "automatic" or "manual" packages).

/usr/lib is for dynamic and static binary libraries (.so or .a), and not for "interpreted" libraries/functions.

Usually, interpreters have different subfolders in /etc/share/ for each version, and inside each version folder, different folders for scripts, locales, tests, samples and so on.

If some day you create an official repository for your package healthchecks, you could migrate your /usr/local/healthchecks contents to /usr/healthchecks and /etc/healthchecks.


I generally try to keep site specific things outside of these reserved system areas. You might consider using your own top-level directory hierarchy as when using system areas special site files can easily get lost or forgotten during system evolution. Another possibility could be /usr/local/etc.....