39

While trying to help a user solve an issue with a bootable USB drive, there seems to be a file that is set so its ownership cannot be edited. I do realize that it should be able to be done with:

sudo chown users:username ldlinux.sys

But when that is executed it gives this error:

Operation not permitted

There is definitely a way to edit the ownership, but I'm all out of ideas. Anyone else got one? If you want to see the thread chat that I was having with the OP, go here! Thanks!

  • 3
    Maybe checking ACLs is an option? I commented on the original question and asked for the output of getfacl ldlinux.sys – Byte Commander Sep 17 '15 at 16:56
  • I think the USB is mounted read-only. Ask OP to check mount options via mount. – muru Sep 17 '15 at 17:30
  • AFAIK it is (users:username) not just the user – userDepth Sep 23 '16 at 19:27
42

Probably the file has the immutable flag set in its extended attributes:

user@user-X550CL ~/tmp % touch immutable
user@user-X550CL ~/tmp % sudo chown root:root immutable
[sudo] password for user:
user@user-X550CL ~/tmp % sudo chattr +i immutable
user@user-X550CL ~/tmp % lsattr immutable
----i--------e-- immutable
user@user-X550CL ~/tmp % sudo chown user:user immutable
chown: changing ownership of 'immutable': Operation not permitted

To fix this, just run sudo chattr -i file:

user@user-X550CL ~/tmp % sudo chattr -i immutable
user@user-X550CL ~/tmp % lsattr immutable
-------------e-- immutable
user@user-X550CL ~/tmp % sudo chown user:user immutable
user@user-X550CL ~/tmp % 
  • 2
    Thanks for the explanation. I forget it again and again. ;) – A.B. Sep 18 '15 at 5:27
  • 16
    I get: chattr: Inappropriate ioctl for device while reading flags on 64GB, while trying this on a usb thumb drive at /media/ – TenLeftFingers Jun 20 '16 at 15:02
  • 3
    For me, the "a" (Append only) flag was the problem. sudo chattr -a fileName solved the problem. – Jonathan Parent Lévesque Sep 20 '16 at 15:42
  • 2
    +1, but fails for some files (not just symlinks), even running as root sudo chattr -i returning chattr: Operation not supported while reading flags. – Brent Faust Oct 16 '17 at 16:35

protected by Community Nov 16 '16 at 14:11

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.