chmod: changing permissions of ‘my_script.sh’: Operation not permitted

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

This should do it. Save the trouble, without creating the file via sudo.

Leave a Comment