Run via $PATH
Run via $PATH#
Even simpler is just to enter the filename of the script. This will work if the script is saved in one of the directories in your $PATH variable.
$PATH looks something like this:
If you place an executable file called
script.bash inside one of those directories (the ones in your
$PATH, not mine) you can run it by just typing
script.bash and pressing Enter. This is a great convenience – it means you can run the script without remembering its path no matter what the current working directory is. It also means you have to write the script to not depend on being in a specific working directory.
/usr/local/sbin is a good place for your system tools, such as background services. /usr/local/bin is a good place for your own command–line tools. The rest of the paths are for the kind of executables provided by system packages. The Filesystem Hierarchy Standard explains this in detail.