reham adel reham adel - 4 months ago 40
Bash Question

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

when I'm trying to make shell script that error is shown ,what i must do ??

[rehamadel@localhost bin]$ sudo vi my_script.sh


[sudo] password for rehamadel:

[rehamadel@localhost bin]$ ls -l my_script.sh


-rw-r--r--. 1 root root 52 Jul 30 19:25 my_script.sh
[rehamadel@localhost bin]$ chmod u+x my_script.sh
chmod: changing permissions of ‘my_script.sh’: Operation not permitted

Answer

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.

Comments