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 1 3 Answers
Resolving the operation not permitted error:
sudo chmod u+x my_script.shYou created the file via:
sudo vi my_script.sh
# editingThis 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.shThis should do it. Save the trouble, without creating the file via sudo.
0You've created file my_script.sh with the root user as the owner (because you used sudo), which is why you're not permitted to change the permissions as yourself.
Thus, use sudo chmod u+x my_script.sh, but note that that will make the file only executable for the root user.
To make the file executable by everyone, use sudo chmod a+x my_script.sh.
I faced this error because I uploaded the files via winscp and was trying to change permission on Linux window. I was able to change permissions via winscp.