Linux file attributes

Have you ever received such an error when you are logged in as root? This error surprised me as I asked myself: Hang on a second! I am the super user, I should be able to change the permission of this regular file.

[root@tux /]# chmod 644 /test
chmod: changing permissions of `/test': Operation not permitted

Look what prevents me from doing this;

[root@tux /]# lsattr /test
-----a-------e- /test

Culprit is the file attribute “a” which means append. With “644” mode, I was trying to remove the write permission from the file but kernel didn’t let me do it because of this bit on. I would appreciate a cleaner error message indeed:) Once I clear the append flag, I successfully changed the permission.

[root@tux /]# chattr -a /test
[root@tux /]# lsattr /test
-------------e- /test
[root@tux /]# chmod 644 /test

There are a couple of more flags I like;

  • A : atime record of the file isn’t modified if set
  • S : changes are written synchronously on the disk
  • i : My favorite, the immutable bit. If set none can modify the file even can create a link

About: rtoodtoo

Worked for more than 10 years as a Network/Support Engineer and also interested in Python, Linux, Security and SD-WAN // JNCIE-SEC #223 / RHCE / PCNSE

You have a feedback?

Discover more from

Subscribe now to keep reading and get access to the full archive.

Continue reading