Linux -- setfacl

SETFACL(1)                                                      Access Control Lists                                                     SETFACL(1)

NAME
       setfacl - set file access control lists

SYNOPSIS
       setfacl [-bkndRLPvh]      [{-m|-x} acl_spec]    [{-M|-X}   acl_file]       file ...

  #注意参数的使用顺序

setfacl --restore=file

DESCRIPTION
       This  utility  sets  Access  Control  Lists  (ACLs)  of files and directories.  On the command line, a sequence of commands is followed by a
       sequence of files (which in turn can be followed by another sequence of commands, ...).

The options -m, and -x expect an ACL on the command line. Multiple ACL entries are separated by comma characters (`,‘). The options -M,  and
       -X read an ACL from a file or from standard input. The ACL entry format is described in Section ACL ENTRIES.

The  --set  and  --set-file options set the ACL of a file or a directory. The previous ACL is replaced.  ACL entries for this operation must
       include permissions.

The -m (--modify) and -M (--modify-file) options modify the ACL of a file or directory.  ACL entries for this operation must include permis‐
       sions.

The  -x  (--remove) and -X (--remove-file) options remove ACL entries. It is not an error to remove an entry which does not exist.  Only ACL
       entries without the perms field are accepted as parameters, unless POSIXLY_CORRECT is defined.

When reading from files using the -M, and -X options, setfacl accepts the output getfacl produces.  There is at most one ACL entry per line.
       After a Pound sign (`#‘), everything up to the end of the line is treated as a comment.

If  setfacl is used on a file system which does not support ACLs, setfacl operates on the file mode permission bits. If the ACL does not fit
       completely in the permission bits, setfacl modifies the file mode permission bits to reflect the ACL as closely as possible, writes an error
       message to standard error, and returns with an exit status greater than 0.

PERMISSIONS
       The  file  owner  and  processes  capable of CAP_FOWNER are granted the right to modify ACLs of a file. This is analogous to the permissions
       required for accessing the file mode. (On current Linux systems, root is the only user with the CAP_FOWNER capability.)

OPTIONS

  -m, --modify=acl 更改文件的访问控制列表
    -M, --modify-file=file 从文件读取访问控制列表条目更改
    -x, --remove=acl 根据文件中访问控制列表移除条目
    -X, --remove-file=file 从文件读取访问控制列表条目并删除

-b, --remove-all
           Remove all extended ACL entries. The base ACL entries of the owner, group and others are retained.
    #删除所有的ACL参数

-k, --remove-default
           Remove the Default ACL. If no Default ACL exists, no warnings are issued.
    #删除默认的ACL参数

-R, --recursive
           Apply operations to all files and directories recursively. This option cannot be mixed with `--restore‘.

-L, --logical
          
Logical walk, follow symbolic links to directories. The default
behavior is to follow symbolic link arguments, and skip  symbolic  links
           encountered in subdirectories.  Only effective in combination with -R.  This option cannot be mixed with `--restore‘.

-P, --physical
          
Physical  walk,  do  not  follow symbolic links to directories.  This
also skips symbolic link arguments.  Only effective in combination
           with -R.  This option cannot be mixed with `--restore‘.

-n, --no-mask
           Do not recalculate the effective rights mask. The default behavior of setfacl is to recalculate the ACL mask entry, unless a mask  entry
           was  explicitly given.  The mask entry is set to the union of all permissions of the owning group, and all named user and group entries.
           (These are exactly the entries affected by the mask entry).

--mask
           Do recalculate the effective rights mask, even if an ACL mask entry was explicitly given. (See the -n option.)

-d, --default
           All operations apply to the Default ACL. Regular ACL entries in the input set are promoted to Default ACL entries. Default  ACL  entries
           in the input set are discarded. (A warning is issued if that happens).

--restore=file
           Restore  a permission backup created by `getfacl -R‘ or similar. All permissions of a complete directory subtree are restored using this
           mechanism. If the input contains owner comments or group comments, setfacl attempts to restore the owner and owning group. If the  input
           contains  flags  comments  (which  define the setuid, setgid, and sticky bits), setfacl sets those three bits accordingly; otherwise, it
           clears them. This option cannot be mixed with other options except `--test‘.

--test
           Test mode. Instead of changing the ACLs of any files, the resulting ACLs are listed.

-v, --version
           Print the version of setfacl and exit.

-h, --help
           Print help explaining the command line options.

--  End of command line options. All remaining parameters are interpreted as file names, even if they start with a dash.

-   If the file name parameter is a single dash, setfacl reads a list of files from standard input.

ACL ENTRIES
       The setfacl utility recognizes the following ACL entry formats (blanks inserted for clarity):

[d[efault]:] [u[ser]:]uid [:perms]
              Permissions of a named user. Permissions of the file owner if uid is empty.

[d[efault]:] g[roup]:gid [:perms]
              Permissions of a named group. Permissions of the owning group if gid is empty.

[d[efault]:] m[ask][:] [:perms]
              Effective rights mask

[d[efault]:] o[ther][:] [:perms]
              Permissions of others.

Whitespace between delimiter characters and non-delimiter characters is ignored.

Proper ACL entries including permissions are used in modify and set operations. (options -m, -M, --set and --set-file).  Entries without the
       perms field are used for deletion of entries (options -x and -X).

For uid and gid you can specify either a name or a number.

The  perms field is a combination of characters that indicate the permissions: read (r), write (w), execute (x), execute only if the file is
       a directory or already has execute permission for some user (X).  Alternatively, the perms field can be an octal digit (0-7).

AUTOMATICALLY CREATED ENTRIES
       Initially, files and directories contain only the three base ACL entries for the owner, the group, and others. There  are  some  rules  that
       need to be satisfied in order for an ACL to be valid:

*   The three base entries cannot be removed. There must be exactly one entry of each of these base entry types.

*   Whenever an ACL contains named user entries or named group objects, it must also contain an effective rights mask.

*   Whenever  an ACL contains any Default ACL entries, the three Default ACL base entries (default owner, default group, and default others)
           must also exist.

*   Whenever a Default ACL contains named user entries or named group objects, it must also contain a default effective rights mask.

To help the user ensure these rules, setfacl creates entries from existing entries under the following conditions:

*   If an ACL contains named user or named group entries, and no mask entry exists, a mask entry containing  the  same  permissions  as  the
           group  entry  is  created. Unless the -n option is given, the permissions of the mask entry are further adjusted to include the union of
           all permissions affected by the mask entry. (See the -n option description).

*   If a Default ACL entry is created, and the Default ACL contains no owner, owning group, or others entry, a copy of the ACL owner, owning
           group, or others entry is added to the Default ACL.

*   If  a Default ACL contains named user entries or named group entries, and no mask entry exists, a mask entry containing the same permis‐
           sions as the default Default ACL‘s group entry is added. Unless the -n option is given, the permissions of the mask  entry  are  further
           adjusted to inclu de the union of all permissions affected by the mask entry. (See the -n option description).

EXAMPLES
       Granting an additional user read access
              setfacl -m u:lisa:r file

Revoking write access from all groups and all named users (using the effective rights mask)
              setfacl -m m::rx file

Removing a named group entry from a file‘s ACL
              setfacl -x g:staff file

Copying the ACL of one file to another
              getfacl file1 | setfacl --set-file=- file2

Copying the access ACL into the Default ACL
              getfacl --access dir | setfacl -d -M- dir

CONFORMANCE TO POSIX 1003.1e DRAFT STANDARD 17
       If  the  environment  variable  POSIXLY_CORRECT is defined, the default behavior of setfacl changes as follows: All non-standard options are
       disabled.  The ``default:‘‘ prefix is disabled.  The -x and -X options also accept permission fields (and ignore them).

AUTHOR
       Andreas Gruenbacher, <[email protected]>.

Please send your bug reports, suggested features and comments to the above address.

SEE ALSO
       getfacl(1), chmod(1), umask(1), acl(5)

May 2000                                                         ACL File Utilities                                                      SETFACL(1)

时间: 2024-11-13 04:03:25

Linux -- setfacl的相关文章

Linux setfacl命令详解

setfacl,命令名,设置文件访问控制列表,即ACL规则.而Acl(Access Control List)就是访问控制列表 setfacl常见命令参数 setfacl 2.2.51 -- 设定文件访问控制列表用法: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...  -m, --modify=acl 更改文件的访问控制列表  -M, --modify-file=file 从文件读取访问控制列表条目更改  -x, --remove=acl 根据文件

操作系统权限

2019-12-23 操作系统权限概述 1)操作系统权限概念说明2)操作系统默认权限设置(调整权限)3)操作系统读取数据原理4)操作系统特殊权限说明(setuid setgid 粘滞位)5)操作系统用户提权配置(sudo)6)操作系统用户相关命令7)操作系统用户相关文件(普通文件/目录文件) 一操作系统文件权限概念 操作系统基本权限:rwx操作系统权限划分:属主   属组     其他用户 对于一个普通文件:r:是否可以查看文件内容(是否可以查看block)w:是否可以编辑文件内容(是否可以改写

Linux ACL权限规划:getfacl,setfacl使用

转载  来源:Linux社区  作者:guodong810 ACL的使用 ACL即Access Control List 主要的目的是提供传统的owner,group,others的read,write,execute权限之外的具体权限设置,ACL可以针对单一用户.单一文件或目录来进行r,w,x的权限控制,对于需要特殊权限的使用状况有一定帮助.如,某一个文件,不让单一的某个用户访问. ACL使用两个命令来对其进行控制    getfacl:取得某个文件/目录的ACL设置项目    setfacl

setfacl命令--Linux命令应用大词典729个命令解读

内容来源于人民邮电出版社<Linux命令应用大词典> 讲述729个命令,1935个例子 学习Linux系统的参考书.案头书,遇到不懂的命令或命令选项一查即可 争取每天都发布内容 本文出自 "airfish2000" 博客,更多命令查看博客: http://airfish2000.blog.51cto.com/10829608/1894364 setfacl命令 使用setfacl命令可以设置文件或目录的ACL. 命令语法: setfacl [选项] [目录|文件] 命令中各

Linux 文件ACL之setfacl和getfacl

前言 近期工作遇到需要多个账号同时需要某个文件的读写权限的,先是尝试用chmod的3大权限来设置,后有前辈指出可用facl设置,查阅资料后,粗略记录实验结果如本章所示:如有遗漏和错误之处,敬请各位看官指出,谢谢. 实验环境: Linux的Distribution: [[email protected] ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.2 (Santiago) setfacl的版本号: [[

Linux中通过setfacl实现目录下创建文件

在Linux 系统中,可以通过setfacl 来实现目录下创建文件或子目录,并继承父目录的权限. 下面以 root 用普通用户 user1 .在目录/mnt下 [[email protected] mnt]# setfacl -m u:user1:rwx share        //为目录添加ower = user1 ,并赋予rwx 的权根. [[email protected]redhat-7 mnt]# setfacl -d -m  u:user1:rwx share    //为目录添加

Linux的ACL规则设置——setfacl及getfacl命令的使用详解

Linux系统中可以针对组.用户.其他人设置不同的读写执行权限,但是还不够精准,若想给某个特定的用户设置一个独特的权限呢?而这个用户又不是该文件或目录的属组或属组,怎么破? 针对特定的某个用户设置权限的方法如下: [[email protected] ~]# dmesg | grep -i acl #查看系统是否可以设置ACL,若可以查到下面标红的字样,则代表没问题. [ 1.173259] systemd[1]: systemd 219 running in system mode. (+PA

Linux:文件访问控制列表 setfacl

setfacl针对单一用户或者用户组,控制wrx权限.针对目录文件,-R递归参数:针对普通文件,-m参数:删除某个文件的ACL,-b参数. [[email protected] ~]# setfacl -Rm u:aa:rwx haha[[email protected] ~]# ls -ld hahadrwxrwx---+ 2 root root 4096 12月 26 11:10 haha**getfacl [[email protected] ~]# getfacl haha 原文地址:h

Linux续-给文件增加用户权限 setfacl -m

1.给文件O 设置读.写.执行,别的用户可以访问,唯有peng1用户不能访问,有针对性查看一下效果再换别的用户,就可以看 原文地址:http://blog.51cto.com/kangxi/2104154