How to make a script executable in Linux
By default whenever a file is created in Linux, it is treated as a normal file and the default privileges would apply.
If you write a script (a file with the .sh extension) you may not be able to use it until it is made an executable file.
To turn your script into an executable file, run the following command:
chmod x <filename>
where <filename> is the name of your script file
If you get the permission denied error try:
sudo chmod x <filename>
Now you can execute the script file.