sudo chmod: operation not permitted

Discussion in 'macOS' started by darakok, Dec 12, 2010.

  1. darakok macrumors newbie

    Jul 21, 2010
    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:
    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.
  2. LPZ macrumors 65816

    Jul 11, 2006
    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.)
  3. Hal Itosis macrumors 6502a

    Hal Itosis

    Feb 20, 2010
    SetFile (and Dev tools) not needed.

    chflags nouchg

    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

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

    Jul 11, 2006
    Thanks. Sadly, I'll forget this before I need it again. :rolleyes:
  5. darakok thread starter macrumors newbie

    Jul 21, 2010
  6. dmass macrumors newbie

    Aug 28, 2012
  7. priya s macrumors newbie

    Oct 24, 2016
    Hi i'm also facing same issue...with zipping a file in mac...what was the solution for this...pls let me
  8. gianlucag macrumors newbie

    Feb 4, 2017
    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

Share This Page