How To Set Attributes by chattr

Setting attributes by chattr


By using chattr +i you can prevent critical files being amended without authorization.

chattr +i /etc/resolv.conf

After that all accounts(include root) will be only have read-only access.


By using chattr +a files can only be appended.

chattr +a /var/log/messages

Checking attributes by lsattr

lsattr checking attributes:

[email protected]:/home# chattr +i test/
[email protected]:/home# lsattr 
-------------e-- ./homeassistant
----i--------e-- ./test
-------------e-- ./pi
[email protected]:/home# cd test/
[email protected]:/home/test# lsattr 
-------------e-- ./2222
-------------e-- ./1111
[email protected]:/home/test#