% setfacl -s user::perms,group::perms,other:perms,mask:perms,acl-entry-list filename ... |
设置文件的 ACL。如果文件已具有 ACL,则会替换该 ACL。此选项要求至少有 user::、group:: 和 other:: 项。
指定文件属主权限。
指定组属主权限。
为文件属主或组成员之外的用户指定权限。
指定 ACL 掩码的权限。掩码表示允许用户(属主除外)和组拥有的最大权限。
指定文件或目录中要为特定用户和组设置的一个或多个 ACL 项的列表。也可以设置目录的缺省 ACL 项。表 6–7 和表 6–8 显示了有效的 ACL 项。
指定要对其设置 ACL 的一个或多个文件或目录。多个 filename 由空格分隔。
如果该文件已存在 ACL,则 -s 选项将使用新的 ACL 替换整个 ACL。
有关更多信息,请参见 setfacl(1) 手册页。
% getfacl filename |
有关更多信息,请参见如何检查文件是否具有 ACL。
在以下示例中,会在 ch1.sgm 文件中将文件属主权限设置为读写、将文件组权限设置为只读,并将其他用户权限设置为无。此外,还在文件中为用户 anusha 指定读写权限。将 ACL 掩码权限设置为读写,这意味着任何用户或组都没有执行权限。
% setfacl -s user::rw-,group::r--,other:---,mask:rw-,user:anusha:rw- ch1.sgm % ls -l total 124 -rw-r-----+ 1 stacey techpubs 34816 Nov 11 14:16 ch1.sgm -rw-r--r-- 1 stacey techpubs 20167 Nov 11 14:16 ch2.sgm -rw-r--r-- 1 stacey techpubs 8192 Nov 11 14:16 notes % getfacl ch1.sgm # file: ch1.sgm # owner: stacey # group: techpubs user::rw- user:anusha:rw- #effective:rw- group::r-- #effective:r-- mask:rw- other:--- |
在以下示例中,会将文件属主权限设置为读写和执行,将文件组权限设置为只读,并将其他用户权限设置为无。此外,还会在 ch2.sgm 文件中将 ACL 掩码权限设置为读。最后,将为用户 anusha 指定读写权限。但是,由于 ACL 掩码的原因,anusha 的权限为只读。
% setfacl -s u::7,g::4,o:0,m:4,u:anusha:7 ch2.sgm % getfacl ch2.sgm # file: ch2.sgm # owner: stacey # group: techpubs user::rwx user:anusha:rwx #effective:r-- group::r-- #effective:r-- mask:r-- other:--- |