55

I am trying to help a user solve an issue with a bootable USB drive, but there seems to be a file whose ownership cannot be edited. I thought it would have been possible with:

sudo chown user:user ldlinux.sys

When that is executed, however, terminal gives this error:

Operation not permitted

The extended chat I had with the user can be found here.

  • 4
    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
  • users:username ?? it is user:group – gaoithe Mar 25 at 17:03
55

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 % 
| improve this answer | |
  • 2
    Thanks for the explanation. I forget it again and again. ;) – A.B. Sep 18 '15 at 5:27
  • 25
    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
  • 4
    +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

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