Author : Piyush Gupta
Chattr – command is useful to change file attributes on Linux second extended file system. It provides more security on your files from unwanted changes and deletes. There are many attributes available to do it.
Chattr – command is useful to change file attributes on Linux second extended file system. It provides more security on your files from unwanted changes and deletes. There are many attributes available to do it.
To Add attributes on a file we use plus (+) and to remove attributes use minus(-) sign . Some impotent attributes are [ASacDdIijsTtu].
How to Use Chattr Command
Add Attribute on File
Create a new file to test this. As example I have crate a new file piyush.txt using touch command and assigned 777 permission on file.
Now enable
i
attribute on file
As you have enabled
i
attribute on file, let’s try to remove this file, you we get following error, even file has 777 permissions.List Attributes of File
To List attributes on a file use
lsattr
command specified with file name.Remove Attributes of File
To clear attribute on a file just use (-) sign with attached attributes. for example in piyush.txt.
Attributes List in Chattr Command
Attribute [ i ]: A file with
i
attribute cannot be modified, it cannot be deleted or renamed by any user included root. Only root can clear this attribute. By this attribute you can keep safe your impotent files from other users or accidental delete.
No comments:
Post a Comment