Is there a standard place for placing custom Linux scripts? [duplicate]
Solution 1:
As far as I know there is no place for custom Linux scripts. The directory that should be used for custom install is the /opt
directory so it would be the safest option to place them there.
But keep in mind that for a script to be able to be used without the full path you need it to be included in the PATH variable.
If you need help changing the PATH
variable for all users you can check How do I set PATH variables for all users on a server? which refers you to the /etc/environment
file to configure this.
If your concern is to avoid clashes but you don't want to add another route to the PATH variable you could use /usr/local/bin
. In my server installation it doesn't have any file so that it could be a easy work-around.
Hope it helps
Solution 2:
/usr/local/bin
seems to be the conventional place, and this directory should be empty on a fresh installs.
Source: The accepted answer on this question:
- Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin
Solution 3:
You could place the scripts in /opt/bin
and add the location to the PATH.
See:
Linux path environment variable
-
Permanently add a directory to shell PATH
For global use in:
/etc/bash.bashrc
or
/etc/profile