There is a file with read only permissions, but even root can't chmod it.

Permissions of the file: -rw-r--r--

After trying to chmod 777:

chmod: changing permissions of ‘motd’: Operation not permitted

I'm doing it from the root account. How is it possible to lock a file like this?

  • 4
    lsattr /etc/motd and check if the immutable bit is set. You will see an i in the output if it is. – MikeA Sep 28 '16 at 16:01
  • 1
    What filesystem is this file on? – Gilles Sep 29 '16 at 0:06
  • Yeah it was lsattr I used chattr and I can change it now, thanks ;) – Furjoza Sep 29 '16 at 8:26

Verify the ownership of the file with

ls -l 

Change ownership of the file with

chown root motd
  • root is the owner ;( -rw-r--r--. 1 root root 989 Sep 19 17:20 motd – Furjoza Sep 28 '16 at 15:52
  • 3
    @Furjoza But the dot at the end of the permission string indicates it has extended permissions. Edit in your question the output of ls -Z /etc/motd and lsattr /etc/motd and lsattr -d /etc – user4556274 Sep 28 '16 at 15:56
  • Root doesn't need to own the file to modify either the file or the properties. – Stephan Sep 28 '16 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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