Resolving the operation not permitted error: sudo chmod u+x my_script.sh You created the file via: sudo vi my_script.sh # editing This means, the owner and group of the file is root. You are not allowed to change files of it by default. You need to change permission (chmod does it) or change the owner: sudo chown you:yourgroup my_script.sh More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.