After all those years working in Linux env and studying on application hardening, I don't know how did I miss "chattr" command.
Specially the attribute "i" is interesting for me, as it allows you to make a file immutable.
From man page of chattr, other attributes you can change are,
- append only (a),
- no atime updates (A),
- compressed (c),
- no copy on write (C),
- no dump (d),
- synchronous directory updates (D),
- extent format (e),
- immutable (i),
- data journalling (j),
- secure deletion (s),
- synchronous updates (S),
- no tail-merging (t),
- top of directory hierarchy (T), and
- undeletable (u).
Following article explains many interesting usage of this command (including disabling user creation by making /etc/passwd file immutable)
https://www.tecmint.com/chattr-command-examples/
You can use lsattr command to see the attributes of the files/folders.
chattr - change file attributes on a Linux file system
Specially the attribute "i" is interesting for me, as it allows you to make a file immutable.
"A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute."
From man page of chattr, other attributes you can change are,
- append only (a),
- no atime updates (A),
- compressed (c),
- no copy on write (C),
- no dump (d),
- synchronous directory updates (D),
- extent format (e),
- immutable (i),
- data journalling (j),
- secure deletion (s),
- synchronous updates (S),
- no tail-merging (t),
- top of directory hierarchy (T), and
- undeletable (u).
Following article explains many interesting usage of this command (including disabling user creation by making /etc/passwd file immutable)
https://www.tecmint.com/chattr-command-examples/
You can use lsattr command to see the attributes of the files/folders.
No comments:
Post a Comment