Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 10 down vote accepted

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

share|improve this answer
    
Thank you for the link - that makes sense! :) –  Richards Jul 7 '11 at 0:03

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.

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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