Change file attribute in Linux

The following command to write protect /root/test.txt file:


[root@localhost]# chattr +i test.txt


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.
The list of Linux second extended file system using the lsatter command (run as root user  )


# lsattr /root/test.txt----i-------- /root/test.txt

For rest of Linux second extended file system attributes read man chatter, man lsatter.

Before doing this root need to remove the attribute using command:

# chattr -i /root/test.txt
# lsattr /root/test.txt------------- /root/test.txt



















0 comments:

Post a Comment