OS X – "sudo chown user file: Operation Not Permitted"

I ran into strange problem today, when I could not change owner or rights of the file, even on admin.

So, after doing some digging, it turns out that there is “immutable” file flag on OS X. This flag obviously makes it impossible to change the file.

Apparently this got set when I moved some data over Samba.

To set immutable flag manually, you have to run:

chflags uchg file

To remove it, you would run:

chflags nouchg file

Here’s what happened:

% ls -lh
-rw-r--r  nobody staff 7.7K   file
% sudo chown otheruser file
chown: file: Operation not permitted
% sudo chflags nouchg file
% sudo chown otheruser file
% ls -lh
-rw-r--r  otheruser staff 7.7K   file

Problem fixed.

2 Responses to “OS X – "sudo chown user file: Operation Not Permitted"”

  1. Paula

    The blog is cool

  2. My Homepage

    … [Trackback]…

    […] There you will find 2744 more Infos: rainbowcoding.com/os-x-sudo-chown-user-file-operation-not-permitted/ […]…


Leave a Reply