Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

bash

shell

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
like image 282
reham adel Avatar asked Jul 30 '16 17:07

reham adel


People also ask

How do I fix Operation not permitted in Linux?

You got this error because your user is not the owner of /root folder. So you can't change the permission of your folder other than the root user. You need to switch to your root account and run the commands as shown below.

What is chmod _x?

chmod +x Add Execute Privilege For User The chmod +x can be used to add execution privilege the current owner user of the specified file. In the following example we will add execution privilege for the user ismail to the file named backup.sh .

How do I give permission to 777 in Linux?

root user run the chmod -R 777 / command and all file permissions for the entire system have read/write/execute for every user.


1 Answers

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.

like image 128
jonas_toth Avatar answered Sep 18 '22 09:09

jonas_toth