linux 文件访问控制列表acl

设置acl命令

setfacl

格式为 setfac 【参数】  文件名称

可以针对单一用户或用户组、单一文件或目录来进行读写执行的权限控制,针对目录需要使用-R 递归处理、针对普通文件使用 -m参数。

使用普通用户查看/root 目录

hh@DESKTOP-0S3GKNK:~$ cd /root/
-bash: cd: /root/: Permission denied

 切换到root用户,给 用户组hh添加 /root 权限  

root@DESKTOP-0S3GKNK:~# setfacl -Rm u:hh:rwx /root

 切换到 hh,可以顺利进入/root

hh@DESKTOP-0S3GKNK:~$ cd /root/
-bash: cd: /root/: Permission denied

  查看/root 下信息

hh@DESKTOP-0S3GKNK:/root$ ls -ld
drwxrwx---+ 6 root root 4096 Aug 25 16:26 .

可以看到文件权限信息中的最后的"." 变成了“+”。

查询acl 信息

getfacl

hh@DESKTOP-0S3GKNK:/root$ getfacl /root
getfacl: Removing leading '/' from absolute path names
# file: root
# owner: root
# group: root
user::rwx
user:hh:rwx
group::---
mask::rwx
other::---

 

posted @ 2022-08-25 16:30  hhanhao  阅读(115)  评论(0编辑  收藏  举报