20170512/5915c8d09766a.jpg

The best life is use of willing attitude, a happy-go-lucky life.

— Mr.Wang

头像

setfacl设置特定目录的权限

发布时间:2017-05-12 21:19:46

发布作者:admin

4110

现有一目录是虚拟机和Linux共享的,但是每次程序调用新建的文件都发现没有权限。

于是指定特定目录及其子目录下新建的文件或目录对于用户qhfz都有读写执行的权限

-R表示递归 -m表示设置文件acl规则

setfacl -R -m u:qhfz:rwx /data2/ResourceCase

setfacl -R -m d:u: ResourceCase:rwx /data2/ResourceCase

--删除ACL规则使用-b

setfacl -R -b /data2/ResourceCase


上面的d:u:详见如下,而perms对应的是rwx:

setfacl命令可以识别以下的规则格式。

[d[efault]:][u[ser]:]uid[:perms]

指定用户的权限,文件所有者的权限(如果uid没有指定)。

[d[efault]:]g[roup]:gid[:perms]

指定群组的权限,文件所有群组的权限(如果gid未指定)

[d[efault]:]m[ask][:][:perms]

有效权限掩码

[d[efault]:]o[ther][:perms]

#perms域是一个代表各种权限的字母的组合:读:r 写:w 执行:x,执行只适合目录和一些可执行的文件。perms域也可设置为八进制格式0~7。

#其他的权限


Usage:setfacl[-bkndRLP]{-m|-M|-x|-X...}file... # -m|-M|-x|-X

-m,--modify=acl modify the current ACL(s)of file(s) #设置文件acl规则

-M,--modify-file=file read ACL entries to modify from file #从文件读取访问控制列表条目更改

-x,--remove=acl remove entries from the ACL(s)of file(s) #删除文件的acl规则

-X,--remove-file=file readACL entries to remove from file #从文件读取访问控制列表条目并删除

-b,--remove-all remove all extended ACL entries # 删除所有扩展的acl规则,基本的acl规则(所有者,群组,其他)将被保留.

-k,--remove-default remove the defaultACL #删除缺省的acl规则。如果没有缺省规则,将不提示.

--set=acl set the ACL of file(s),replacing the current ACL.

--set-file=file readACL entries toset from file #从文件中读设置ACL规则.

--mask dorecalculate the effective rights mask #重新计算有效权限,即使ACL mask被明确指定.

-n,--no-mask don'trecalculate the effective rights mask #不要重新计算有效权限。setfacl默认会重新计算ACL mask,除非mask被明确的制定.

-d,--default operations apply tothe defaultACL #设定默认的acl规则,针对目录而言.

-R,--recursive recurse into subdirectories #递归的对所有文件及目录进行操作.

-L,--logical logical walk,follow symbolic links #跟踪符号链接,默认情况下只跟踪符号链接文件,跳过符号链接目录。

-P,--physical physical walk,donotfollow symbolic links #跳过所有符号链接,包括符号链接文件。

--restore=file restore ACLs(inverse of`getfacl-R') #从文件恢复备份的acl规则(这些文件可由getfacl -R产生)。通过这种机制可以恢复整个目录树的acl规则。此参数不能和除--test以外的任何参数一同执行.

--test testmode(ACLs are notmodified) #测试模式,不会改变任何文件的acl规则,操作后的acl规格将被列出.

-v,--version print version andexit #版本.

-h,--help thishelp text #不用说肯定是帮助了.

当使用-M,-X选项从文件中读取规则时,setfacl接受getfacl命令输出的格式。每行至少一条规则,以#开始的行将被视为注释.


相关文章:
  1. 多用户SS平台搭建教程
  2. koolshare写入U盘制作软路由
  3. node.js 进程守护forever
  4. Thinkphp V5.X 远程代码执行漏洞-POC集合