文件属性 chattr
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
文件权限管理之: 文件属性
注:设置文件属性(权限),针对所有用户,包括root
[root@localhost ~]# man chattr[root@localhost ~]# chattr +a file1
[root@localhost ~]# chattr +i file2
[root@localhost ~]# chattr +A file3
[root@localhost ~]# lsattr file1 file2 file3
-----a-------e- file1
----i--------e- file2
-------A-----e- file3
[root@localhost ~]# echo 111 > file1 //以覆盖的方式写入
bash: file1: Operation not permitted
[root@localhost ~]# rm -rf file1
rm: cannot remove `file1': Operation not permitted
[root@localhost ~]# echo 111 >> file1 //以追加的方式写入,例如日志文件
[root@localhost ~]# echo 111 > file2
bash: file2: Permission denied
[root@localhost ~]# echo 111 >> file2
bash: file2: Permission denied
[root@localhost ~]# rm -rf file2
rm: cannot remove `file2': Operation not permitted
[root@localhost ~]# chattr -a file1
[root@localhost ~]# chattr -i file2
[root@localhost ~]# chattr -A file3