文件屬性 chattr

文件屬性 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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章