Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

darakok

macrumors newbie
Original poster
Jul 21, 2010
23
0
Dear mac users,

I want to change permission on a file using this command below, but it doesn't work. it seems there is a permission problem or the file is locked in some way.

what i get as a result is:
Code:
sudo chmod g+rwx "Copy of index.php" 

chmod: Unable to change file mode on Copy of index.php: Operation not permitted

the error happens when i try to change file owner ship. There are other files in the folder, and my above command works except this one file.

Please help.
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
Dear mac users,

I want to change permission on a file using this command below, but it doesn't work. it seems there is a permission problem or the file is locked in some way.

what i get as a result is:
Code:
sudo chmod g+rwx "Copy of index.php" 

chmod: Unable to change file mode on Copy of index.php: Operation not permitted

the error happens when i try to change file owner ship. There are other files in the folder, and my above command works except this one file.

Please help.

To test, I created a new file and then locked it. I then entered your command and received the same message you received. So it seems your guess about the file being locked is correct.

You can try to unlock the file using Finder:

1) In the Finder Go menu, choose Go to Folder.

2) Type in the path to the folder that contains the file, and then click Go.

3) In the window that opens, select the file and then select Get Info from the Finder File menu.

4) In the panel that opens, uncheck the Locked box in the General section of the panel.

(This can also be accomplished from Terminal using the SetFile command, but unless you've installed the Developer Tools, I don't think you have this command on your system.)
 

Hal Itosis

macrumors 6502a
Feb 20, 2010
900
4
(This can also be accomplished from Terminal using the SetFile command, but unless you've installed the Developer Tools, I don't think you have this command on your system.)
SetFile (and Dev tools) not needed.

chflags nouchg
/path/to/item

will do that trick as well (and chflags comes on all OSX Macs).

--

Probably the most important command for users to learn is ls

ls -lOe
/path/to/item

will show what's preventing the mode change.
Could be a lock (flag) or could be an ACL too.
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
SetFile (and Dev tools) not needed.

chflags nouchg
/path/to/item

will do that trick as well (and chflags comes on all OSX Macs).

--

Probably the most important command for users to learn is ls

ls -lOe
/path/to/item

will show what's preventing the mode change.
Could be a lock (flag) or could be an ACL too.

Thanks. Sadly, I'll forget this before I need it again. :rolleyes:
 
  • Haha
Reactions: svanstrom

gianlucag

macrumors newbie
Feb 4, 2017
1
0
I solved the issue copying the file, assigning the right permission to it (now it can be done as it is a brand new file), removing the old one and renaming the new file as the old one. Job done
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.