隐藏权限lsattr_chattr
添加特殊权限:
[root@localhost ~]# touch 1.txt
[root@localhost ~]# chattr +i 1.txt
[root@localhost ~]# head -n2 passwd > 1.txt
-bash: 1.txt: 权限不够
- 添加i权限后,不能删、不能写入、创建时间也不能更改
查看权限:
[root@localhost ~]# lsattr 1.txt
----i----------- 1.txt
- 新建普通文件是没有i权限的
删除特殊权限:
[root@localhost ~]# chattr -i 1.txt
[root@localhost ~]# lsattr 1.txt
---------------- 1.txt
- chattr +a 添加a权限
- 添加a权限后,只能追加,不能删除和更改
[root@localhost ~]# chattr +a 1.txt
[root@localhost ~]# lsattr 1.txt
-----a---------- 1.txt
[root@localhost ~]# echo "aaaaaa" >> 1.txt
目录添加特殊权限:
[root@localhost ~]# mkdir 111
[root@localhost ~]# chattr +i 111
[root@localhost ~]# rm -r 111
rm:是否删除目录 "111"?
rm: 无法删除"111": 不允许的操作
目录添加a权限:
[root@localhost ~]# chattr +a 111
[root@localhost ~]# touch 111/12.txt
[root@localhost ~]# echo "aaaaaa" >> 12.txt
- 目录添加a权限后,不可以创建文件,但可以修改已存在文件的内容
- lsattr -R 111 查看111目录下的子目录及子目录下的文件(只查看一层)