ACL即Access Control List 主要的目的是提供传统的owner,group,others的read,write,execute权限之外的具体权限设置,ACL可以针对单一用户、单一文件或目录来进行r,w,x的权限控制,对于需要特殊权限的使用状况有一定帮助。如,某一个文件,不让单一的某个用户访问。
ACL使用两个命令来对其进行控制
getfacl:取得某个文件/目录的ACL设置项目
setfacl:设置某个文件/目录的ACL设置项目
通过-h 参数,来确认对getfacl setfacl 2个命令的使用
[root@xxx~]# getfacl -h
getfacl 2.2.39 -- get file access control lists
Usage: getfacl [-dRLPvh] file ...
--access display the file access control list only
-d, --default display the default access control list only
--omit-header do not display the comment header
--all-effective print all effective rights
--no-effective print no effective rights
--skip-base skip files that only have the base entries
-R, --recursive recurse into subdirectories
-L, --logical logical walk, follow symbolic links
-P --physical physical walk, do not follow symbolic links
--tabular use tabular output format
--numeric print numeric user/group identifiers
--absolute-names don't strip leading '/' in pathnames
-v, --version print version and exit
-h, --help this help text
[root@xxx~]# setfacl -h
setfacl 2.2.39 -- set file access control lists
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
-m, --modify=acl modify the current ACL(s) of file(s)
-M, --modify-file=file read ACL entries to modify from file
-x, --remove=acl remove entries from the ACL(s) of file(s)
-X, --remove-file=file read ACL entries to remove from file
-b, --remove-all remove all extended ACL entries
-k, --remove-default remove the default ACL
--set=acl set the ACL of file(s), replacing the current ACL
--set-file=file read ACL entries to set from file
--mask do recalculate the effective rights mask
-n, --no-mask don't recalculate the effective rights mask
-d, --default operations apply to the default ACL
-R, --recursive recurse into subdirectories
-L, --logical logical walk, follow symbolic links
-P, --physical physical walk, do not follow symbolic links
--restore=file restore ACLs (inverse of `getfacl -R')
--test test mode (ACLs are not modified)
-v, --version print version and exit
-h, --help this help text
通过测试对2个命令的使用
以root用户创建11 目录
mkdir 11
使用setfacl 命令进行设置
[root@xxx ]# setfacl -m u:us11:rw 11
这样用户us11就能正常进入这个目录了。
查询使用getfacl
[root@xxx us11]# getfacl 11
# file: 11
# owner: root
# group: root
user::rwx
user:us11:rw-
group::r-x
mask::rwx
other::---