Chown operation not permitted for root

I try to chown the owner of a file to root, but I can't. I'm doing this as root. I get the following message:

chown: changing ownership of `ps': Operation not permitted

Solution 1:

The immutable attribute might be set on the file. Remove it with

chattr -i <file>

Solution 2:

Several solution exists, some among them:

  • you have a filesystem does not lets you eg. uid:gid, eg: FAT
  • the drive has been mounted read-only
  • SELinux or other security enforcers apply
  • filesystem is set to read-only mode (xfs_freeze, for example)
  • file has the immutable flag set (man chattr)

Solution 3:

I had same problem.

$ chattr -V -i dir
chattr 1.41.12 (17-May-2010)
Flags of dir set as s----a---------

Which was not enough. So i added the 'sa'

$ chattr -V -ais dir
chattr 1.41.12 (17-May-2010)
Flags of dir set as ---------------
$ chown root dir
$

Problem solved :)