Rainbow Coding

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

OSX file permissions wont allow you to change ownership when protected with immutable flag.

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.

© RainbowCoding 2010-2021