Linux自学--4⃣️文件权限

  1. 文件的一般权限
[root@localhost test]# ls -l
  total 0
  drwxr-xr-x. * root root 6 Feb 10 17:30 test
  -rw-r--r--+ 1 root root 0 Feb 10 17:30 test.txt
#  [文件属性]   [所有者][所属组]            
属性信息代表含义
drwxr-xr-xd[目录文件]rwx[所有者权限]r-x[所有组权限]r-x[其他人权限]
-rw-r- -r- --[普通文件]rw-[所有者权限]r- -所有组权限]r- -[其他人权限]
.是否设置了文件访问控制列表。(否)
+是否设置了文件访问控制列表。(是)
*文件的inode链接个数。
r读取权限,使用数字4来表示。 在目录文件上代表读取目录内文件列表。
w写入权限,使用数字2来表示。在目录文件上代表可在目录内创建或删除文件。
x执行权限,使用数字1来表示。 在目录文件上代表可以切换进该目录。
  1. 文件的特殊权限
    在这里插入图片描述
[root@localhost test]# ls -l
total 0
-rwxrwxrwx. 1 root root 0 2月  10 18:22 1
-rw-rw-rw-. 1 root root 0 2月  10 18:22 2
[root@localhost test]# chmod 7777 1
[root@localhost test]# chmod 7666 2
[root@localhost test]# ls -l
total 0
-rwsrwsrwt. 1 root root 0 2月  10 18:22 1
-rwSrwSrwT. 1 root root 0 2月  10 18:22 2
  1. 文件的隐藏属性
[root@localhost ~]# chattr -f +Aadi 1	#设置文件隐藏属性
[root@localhost ~]# ls -l 1
-rwxr-xr-x. 1 root root 0 2月  10 18:22 1
[root@localhost ~]# lsattr 1        	#查看文件隐藏属性
----iadA-------- 1		
[root@localhost ~]# chattr -f -Aadi 1	#取消文件隐藏属性
[root@localhost ~]# lsattr 1 
---------------- 1
参数作用
i无法对文件进行修改;对目录设置了该参数,仅能修改文件内容而不能新建或删除文件
a仅允许补充(追加)内容,无法覆盖/删除内容
S文件内容在变更后立即同步到硬盘
s彻底从硬盘中删除,不可恢复
A不再修改这个文件或目录的最后访问时间(atime)
b不再修改文件或目录的存取时间
D检查压缩文件中的错误
d使用dump命令备份时忽略本文件/目录
c默认将文件或目录进行压缩
u当删除该文件后依然保留其在硬盘中的数据,方便日后恢复
t让文件系统支持尾部合并(tail-merging)
x可以直接访问压缩文件中的内容
  1. 文件访问控制列表

    文件的ACL提供的是在属主、属组、其他人的读/写/执行权限之外的特殊权限控制,使用setfacl命令可以针对单一用户或用户组、单一文件或目录来进行读/写/执行权限的控制。
    针对目录文件需要使用-R递归参数;针对普通文件则使用-m参数;如果想要删除某个文件的ACL,则可以使用-b参数。
    如果针对某个目录设置了ACL,则目录中的文件会继承其ACL;若针对文件设置了ACL,则文件不再继承其所在目录的ACL。

   [root@localhost test]# ls -l
   total 8
   d---------. 2 root root 6 2月  10 21:51 test
   ----------. 1 root root 0 2月  10 18:20 test.txt
   [root@localhost test]# setfacl -Rm u:admin:rwx test
   [root@localhost test]# setfacl -m u:admin:rwx test.txt
   [root@localhost test]# su - admin	
   [admin@localhost test]$ ls -l
   total 8
   d---rwx---+ 2 root root 6 2月  10 21:51 test
   ----rwx---+ 1 root root 0 2月  10 18:20 test.txt
   [admin@localhost test]$ getfacl test
   # file: test
   # owner: root
   # group: root
   user::rwx
   "user:admin:rwx"
   group::---
   mask::rwx
   other::---
   [root@localhost test]# setfacl -b test
   [root@localhost test]# getfacl test
   # file: test
   # owner: root
   # group: root
   user::rwx
   group::---
   other::---	


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值