chattr : chattr is a command in the Linux operating system that allows a user to set certain attributes on a file residing on an ext2/ext3/ext4 based filesystem.
Syntax :
#chattr [operator] [switch] [file name]
Operator :
+ Add attribute.
- Remove attribute.
= Assign attributes (removing unspecified attributes)
- Remove attribute.
= Assign attributes (removing unspecified attributes)
Switch :
-R Recursively change attributes of directories and their contents. Symbolic links encountered during recursive directory traversals are ignored.
-a A file with the ‘a’ attribute set can only be open in append mode for writing. Only the superuser can set or clear this attribute.
-i 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 can set or clear this attribute.
Example 1:
Example 2 :
Main difference between a and i switch is in i you cannot append the file while in a switch you can append the file.
Example 3:
0 comments:
Post a Comment