两个命令主要是不允许别人修改、删除或者只允许添加,
应用实例。
[root@localhost test1]# chattr +i 1.txt
[root@localhost test1]# mv 1.txt 1
[root@localhost test1]# mkdir 1
[root@localhost test1]# mv 1.txt 1
mv: 无法将”1.txt” 移动至”1/1.txt”: 不允许的操作
[root@localhost test1]# lsattr 1.txt
—-i——–e- 1.txt
//只能给文件增加内容不能修改。
[root@localhost test1]# chattr +a 1.txt
[root@localhost test1]# lsattr 1.txt
—-ia——-e- 1.txt
[root@localhost test1]# rm 1.txt
rm:是否删除普通空文件 “1.txt”?
[root@localhost test1]# rm 1.txt
rm:是否删除普通空文件 “1.txt”?y
rm: 无法删除”1.txt”: 不允许的操作
[root@localhost test1]#
lsattr [ -RVadv ] [ files… ]
-R Recursively list attributes of directories and their contents.
-V Display the program version.
-a List all files in directories, including files that start with
`.'.
-d List directories like other files, rather than listing their
contents.
-v List the file's version/generation number.
chattr [ -RVf ] [ -v version ] [ mode ] files…
-R Recursively change attributes of directories and their contents.
-V Be verbose with chattr's output and print the program version.
-f Suppress most error messages.
-v version
Set the file's version/generation number