The shell maintains a list of directories where executable files (programs) are kept, and just searches the directories in that list. If it does not find the program after searching each directory in the list, it will issue the famous
command not found error message. This list of directories is called your path. You can view the list of directories with the following command:
You can add directories to your path with the following command, where
*directory* is the name of the directory you want to add:
A better way would be to edit your
.bash_profile file to include the above command. That way, it would be done automatically every time you log in.
Most modern Linux distributions encourage a practice in which each user has a specific directory for the programs he personally uses. This directory is called
bin and is a subdirectory of your home directory. If you do not already have one, create it with the following command:
Move your script into your new
bin directory and you're all set. Now you just have to type:
and your script will run.