Changing Ownership: "Operation not permitted" - even as root!
395,021
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 %
Related videos on Youtube
![David](https://i.stack.imgur.com/55EH1.jpg?s=256&g=1)
Author by
David
Computer Engineering Tech Major Fluent in .NET, bash, and TypeScript AU User since mid-2015 Using ubuntu since 9.04
Updated on September 18, 2022Comments
-
David almost 2 years
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.
-
Byte Commander almost 9 yearsMaybe checking ACLs is an option? I commented on the original question and asked for the output of
getfacl ldlinux.sys
-
muru almost 9 yearsI think the USB is mounted read-only. Ask OP to check mount options via
mount
. -
userDepth almost 8 yearsAFAIK it is (users:username) not just the user
-
gaoithe over 4 yearsusers:username ?? it is user:group
-
-
A.B. almost 9 yearsThanks for the explanation. I forget it again and again. ;)
-
TenLeftFingers about 8 yearsI get: chattr: Inappropriate ioctl for device while reading flags on 64GB, while trying this on a usb thumb drive at /media/
-
Jonathan Parent Lévesque almost 8 yearsFor me, the "a" (Append only) flag was the problem.
sudo chattr -a fileName
solved the problem. -
Brent Faust over 6 years+1, but fails for some files (not just symlinks), even running as root
sudo chattr -i
returningchattr: Operation not supported while reading flags.
-
harperville over 3 yearsMy USB has
msdos
filesystem. Found this: unix.stackexchange.com/questions/552121/… so I went ahead and reformatted as ext4 per askubuntu.com/questions/149984/… -
sonrad10 almost 3 yearsYou get the
Operation not supported
error when trying to mount a Windows filesystem (exFat/NTFS) with incorrect mount options. You can either reformat your drive to ext4, or simply change the mount options with this answer: askubuntu.com/a/956072/612853 -
linstar over 2 yearsThanks kos, this solved it for me just now.. But, man chattr doesn't even list -i as an option! So, thanks again.