Sudo chown “Operation not permitted” – how to resolve permissions to allow chown by admin or root users

extended-attributespermissionterminal

As sanity check I was sudo chowning some folders due to having run some commands previously that generated some root owned files in my $HOME. I ended seeing an error in this process that got me curious:

chown: Library/Caches/com.mailplaneapp.Mailplane3/my@domain.tld/Downloads/151623a0c45f2b4_0.1.pdf: Operation not permitted

ls -l@ Library/Caches/com.mailplaneapp.Mailplane3/my@domain.tld/Downloads/151623a0c45f2b4_0.1.pdf doesn't reveal anything overly remarkable in this regard:

-rw-r--r--@ 1 USERNAME  staff  335080 Aug 17  2018 Library/Caches/com.mailplaneapp.Mailplane3/my@domain.tld/Downloads/151623a0c45f2b4_0.1.pdf
    com.apple.metadata:kMDItemWhereFroms       284

I noticed this same thing from other files in this folder. Is there something I can do to strip whatever permissions might be preventing an admin / root user from modifying ownership via chown?

Best Answer

Try either or both of these commands:

sudo chflags noschg '/path/to/file.ext'

sudo chflags nouchg '/path/to/file.ext'