I've written a basic command line application composed of multiple bash scripts. One of these is intended to be run by any user of the computer, so I understand the correct location for this would be /usr/local/bin/.

The other scripts should not be directly run by the user, but called only by the first script. Security isn't an issue here, I don't mind if the user goes to the trouble of finding their exact path and executing them from there, but I don't want them in a path that means they can be called from anywhere.

Currently I've got them all in /usr/sbin/my_app_name/ but I understand I shouldn't really be putting stuff there. But where should I put such scripts? Ideally I'd like to just move the my_app_name folder, which contains the scripts, to the correct location.

  • /var/lib/my_app_name/ May 16 '13 at 16:18
  • 1
    why don't you want to place them with the other callable script? That's what they are so that's where they belong. And if they really are only used by the "general" script, why don't you make them into functions of that script in which case you will have a single file?
    – carandraug
    May 16 '13 at 16:27
  • 1
    The place for stuff "called internally" is /usr/libexec or some such.
    – vonbrand
    May 16 '13 at 16:47

TL;DR: Put supporting files in /usr/local/lib/my_app_name and main script in /usr/local/bin.

Of course you will get many suggestions for different places to put things, as there is not much standardization for this kind of thing. I prefer to put files of this type in /usr/local/my_app_name/ or /opt/local/my_app_name, depending on where you install additional user programs on your system. The main program should be in /usr/local/bin or /opt/local/bin. If the subsidiary scripts are not meant to be run on their own, they probably shouldn't be in the same location as the main script. However, if the subsidiaries are full modules/libraries in their own right that could be called by other programs, then a location like /usr/local/lib might be appropriate.

For future reference, check out the Filesystem Hierarchy Standard. The recommendations for /usr/local and /opt (I get /opt/local from OSX and MacPorts) are similar, though it seems that /opt is more for external packages you might get from a vendor - for example, Intel's Math Kernel Library installs itself by default in /opt/intel/mkl.

  • @AntonChanning - I added an update to clarify things...
    – MattDMo
    May 17 '13 at 15:28
  • Thanks. This makes a lot of sense. I didn't accept the answer right away because I didn't know enough to judge if it was right. Good update. May 18 '13 at 9:31

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.