Have you ever created a python script and wondered why when you attempt to execute the program from the command prompt, it states that the command was not found or something similar. This is because the system does not know the location of the file. The system executes programs in one of the directories listed in the PATH environment variable.
To determine the directories in the PATH environment variable, enter the following at the command shell:
$ echo $PATH
We can display the PATH variable using the echo command and prefixing the variable name by $ to indicate to the shell that we need the value of this variable. There are two ways of executing your program without having to go directly to the path which it exist. One way is you can store your program in one of the directories listed in the PATH variable, or you can add a directory to the PATH variable itself.
Option 1. Determine the available paths in the PATH variable and add your program to the directory
$ echo $PATH
$ cp python.py /usr/local/bin
$ python
Option 2. Add a directory of your choose to the PATH variable
$ PATH=$PATH:/usr/yourdir
This is very useful for script that you may want to run anywhere at anything.