English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Linux chattr command is used to change file attributes.
This command can change the files stored in ext2File or directory attributes on the file system, these attributes have the following8There are modes:
chattr [-RV][-v<version number>][+/-/=<attribute>][file or directory...]
-R Recursive processing, process all files and subdirectories in the specified directory.
-v<version number> Set the version of the file or directory.
-V Display the execution process of the command.
+<attribute> Open the specified attribute of the file or directory.
-<attribute> Close the specified attribute of the file or directory.
=<attribute> Specify the specified attribute of the file or directory.
Use the chattr command to prevent a critical file in the system from being modified:
chattr +i /etc/resolv.conf
lsattr /etc/resolv.conf
It will display the following attributes:
----i-------- /etc/resolv.conf
Let a file only append data inside it, but not delete, suitable for various log files:
chattr +a /var/log/messages