Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have many bash scripts on my server, that all users may use.

but it seems the location

/usr/local/sbin

is not the best place.

I don't want to use the home directory of the users, cause everybody may execute them.

is there a convention about where to store them on Debian?

share|improve this question
2  
/usr/local/bin is the usual place for this –  Nifle May 15 '13 at 12:26

1 Answer 1

up vote 4 down vote accepted

The "official" place for local executables is /usr/local/bin. This directory is usually in the $PATH of all users by default. Traditionally, programs that are not installed through a package manager (eg apt) are stored in the /usr/local/bin directory and those installed by the package manager in /usr/bin. See here for some more information and here for the official definitions and more details than you will ever need.

These are just conventions though and you are free to use your own directory. For example, to store scripts that can be executed by all users in /usr/local/scripts you would need to follow these steps:

  1. Create the directory (I am assuming you have sudo configured, if not just switch to root with su) and allow execution:

    sudo mkdir /usr/local/scripts
    sudo chmod 755 /usr/local/scripts
    
  2. Add this directory to all user's $PATHs (this assumes everyone is using bash). Add this line to /etc/profile:

    export PATH=$PATH:/usr/local/scripts
    

A better way (as @Michał Šrajer pointed out in the comments) that will work for most shells (at least any that use the pam_env module would be to set the $PATH in /etc/environment. For example:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/scripts"
share|improve this answer
    
In debian PATH is set globally in /etc/environment. BTW, since Squeeze, Bash is no longer default shell. Dash is. –  Michał Šrajer May 15 '13 at 13:27
    
I wonder why I should store a plain-text script in a folder called "bin" or "sbin"? Aren't "binaries" compiled files, that are non-text? –  rubo77 May 15 '13 at 16:27
    
Strictly speaking yes, that is what binaries are. However, by convention all executables are stored in the various bin directories. For example, on my system, /usr/bin contains 2061 compiled binary files and 3888 scripts (text files). –  terdon May 15 '13 at 16:36

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.