5

I wrote a small bash script for starting, stopping and restarting my java applications and I want to make it available to all users so they could run it. Should I just place it in /usr/bin to do that? Is it the right place for my scripts? Isn't that for like installed package script and stuff only?

10

Correct, [/usr]/[s]bin is for the distro creator's use. Local user scripts belong under /usr/local, specifically /usr/local/bin in this case.

Filesystem Hierarchy Standard

1

I would recommend putting it in /opt. You can create directory with your application name under /opt and then bin directory under it, so your path will look like that:

/opt/<your_app_name>/bin

Then you create two scripts in /etc/profile.d - <your_app_name>.sh and <your_app_name>.csh and in those scripts you add the path above to global $PATH variable to make executables of your app available to all users. That's all.

I think that this approach is cleaner then putting it in /usr/local/bin since all your changes to the system are localized to a single directory (with exception of two scripts in /etc/profile.d), it is easy to remove your app manually and your files do not mix with files of other applications (which may be the case with /usr/local). This approach is also compliant with "Filesystem Hierarchy Standard".

0

There is certainly nothing preventing you from placing a script in /usr/bin, giving it world-execute permissions (something like chmod 755) and allowing users to run it. If you want to conform with "The UNIX way" there are more appropriate locations. I'm sure I'll start a trail of comments on why this is wrong, but I'd learn towards storing it in /usr/local/bin/ instead. The /usr/local directory is typically for software not managed by the distribution directly, such as third party applications or scripts.

  • 3
    Actually, /usr/local is for second-party stuff. Third-party stuff goes under /opt. – Ignacio Vazquez-Abrams Jul 6 '11 at 23:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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