Can I place my script in /usr/bin?

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?


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


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".


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.