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?
Answer
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:
Create the directory (I am assuming you have
sudo
configured, if not just switch toroot
withsu
) and allow execution:sudo mkdir /usr/local/scripts
sudo chmod 755 /usr/local/scriptsAdd 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"
Comments
Post a Comment