file owner cannot chmod file, report operation not permitted

27,825

Check to see if the file is set as immutable.

root@hostname:/tmp# lsattr ./a.out
----i--------e-- a.out

That i means the file is immutable and cannot be changed. You have to use chattr -i ./a.out to clear the flag, and then +i to re-enable after making changes.

Share:
27,825

Related videos on Youtube

Hao Liu
Author by

Hao Liu

Updated on September 18, 2022

Comments

  • Hao Liu
    Hao Liu almost 2 years
    1. use root copy or create a file a.out
    2. chown user:user a.out, change a.out owner to user
    3. now change to user, su user
    4. use user to chmod a.out, chmod 755 a.out
    5. Ok, problem is here. step 4 will output : chmod: ./a.out: Operation not permitted

    I run these step on SUSE, it's work. And chmod can use by file owner or root. So, i think this maybe a bug on Ubuntu. Anyone know this?

    • Rinzwind
      Rinzwind over 7 years
      "So, i think this maybe a bug on Ubuntu." doubt it. More likely the directory above where you did this? Or immutable flag? Or ACL.
    • muru
      muru over 7 years
      Could not reproduce
  • Hao Liu
    Hao Liu over 7 years
    . directory is user, but .. is root
  • marosg
    marosg over 7 years
    Can you post output of the command ? And also output of "lsattr a.out"