Where to store bash scripts that all users may execute on Debian?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Ominous Technology Looping
--
Chapters
00:00 Where To Store Bash Scripts That All Users May Execute On Debian?
00:28 Accepted Answer Score 11
01:35 Thank you
--
Full question
https://superuser.com/questions/595828/w...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#bash #debian #path
#avk47
ACCEPTED ANSWER
Score 11
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/scripts
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"