1. 程式人生 > >linux權限管理之文件屬性

linux權限管理之文件屬性

localhost touch linux權限 denied 管理 所有 -a remove 設置

文件屬性 chattr


========================================================

文件權限管理之: 文件屬性
註:設置文件屬性(權限),針對所有用戶,包括root
[root@localhost ~]# touch file100 file200 file300
[root@localhost ~]# lsattr file100 file200 file300
-------------e- file100
-------------e- file200
-------------e- file300

[root@localhost ~]# man chattr
[root@localhost ~]# chattr +a file100

[root@localhost ~]# chattr +i file200
[root@localhost ~]# chattr +A file300

[root@localhost ~]# lsattr file100 file200 file300
-----a-------e- file100
----i--------e- file200
-------A-----e- file300

[root@localhost ~]# echo 111 > file100 //以覆蓋的方式寫入
bash: file100: Operation not permitted
[root@localhost ~]# rm -rf file100
rm: cannot remove `file100‘: Operation not permitted
[root@localhost ~]# echo 111 >> file100 //以追加的方式寫入,例如日誌文件

[root@localhost ~]# echo 111 > file200
bash: file200: Permission denied
[root@instructor ~]# echo 111 >> file200
bash: file200: Permission denied
[root@localhost ~]# rm -rf file200
rm: cannot remove `file200‘: Operation not permitted

[root@localhost ~]# chattr -a file100
[root@localhost ~]# chattr -i file200
[root@localhost ~]# chattr -A file300

linux權限管理之文件屬性