English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Linux lsattr command is used to display file attributes.
Use chattr to change the attributes of files or directories, and use lsattr to query their attributes.
lsattr [-adlRvV][file or directory...]
Parameters:
1Use chattr command to prevent a key file in the system from being modified:
# chattr +i /etc/resolv.conf
Then use mv /etc/Operations such as resolv.conf on this file result in Operation not permitted.
When editing the file with vim, it will prompt W10: Warning: Changing a readonly file error. To modify this file, you need to remove the i attribute:
chattr -i /etc/resolv.conf
Use the lsattr command to display file attributes:
# lsattr /etc/resolv.conf
Output result is:
----i-------- /etc/resolv.conf
2Set a file to only append data and not delete, suitable for various log files:
# chattr +a /var/log/messages