Linux下的ACL
ACL理论概述
9位的属主/属组/其他人访问控制系统已经得到证明是强大的,足以满足大多数管理方面的需求。
事实上,在所有非UNIX操作系统上都采用了一种实质上更为复杂的方式来管理对于文件的访问:访问控制列表(access control list),简称ACL。ACL不限制长度,可以包含用于多个用户或者用户组的权限规定。更先进的系统能让系统管理员指定部分权限的集合或者否定方式的权限。
因为在POSIX规范中增加了ACL,所以许多UNIX的变体也开始支持一种相当标准的ACL机制,这种机制和传统的UNIX 9位权限模式平行地发挥左右。
Linux的ACL主要是对标准的9位权限模型直接进行扩展。ACL可以按照用户和用户组的任意组合独立地设置rwx权限位。
ACL的主要命令
getfacl 命令可以显示一个文件当前的ACL
$ getfacl --help
getfacl 2.2. -- get file access control lists
Usage: getfacl [-aceEsRLPtpndvh] file ...
-a, --access display the file access control list only
-d, --default display the default access control list only
-c, --omit-header do not display the comment header
-e, --all-effective print all effective rights
-E, --no-effective print no effective rights
-s, --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
-t, --tabular use tabular output format
-n, --numeric print numeric user/group identifiers
-p, --absolute-names don't strip leading '/' in pathnames
-v, --version print version and exit
-h, --help this help text
setfacl 命令可以修改或者设置文件当前的ACL
$ setfacl --help
setfacl 2.2. -- 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
ACL实例
1. ACL随着chmod命令对权限模式位的修改而自动更新
$ touch example
$ ls -l example
-rw-rw-r-- eric eric Dec : example
$ getfacl example
# file: example
# owner: eric
# group: eric
user::rw-
group::rw-
other::r--
$ chmod example
$ getfacl --omit-header example
user::rw-
group::r--
other::---
2. Mask规定了ACL能够给单个组和用户访问权限的上限。扩充上一个例子里的ACL,让它包括对某个特定用户和组的ACL,setfacl会自动提供一个合适的mask
$ ls -l example
-rw-r----- eric eric Dec : example
$ setfacl -m user::r,user:squid:rw,group:squid:rw example
$ ls -l example
-r--rw----+ eric eric Dec : example
$ getfacl --omit-header example
user::r--
user:squid:rw-
group::r--
group:squid:rw-
mask::rw-
other::---
如上所示,setfacl命令产生了一个mask,让ACL中赋予的所有权限都发生了作用。在尝试访问文件的时候,要把有效UID同该文件属主的UID进行对比。如果他们一样,那么ACL中user::项权限就决定了能否访问。否则,匹配某个特定用户的ACL项,那么ACL项连同ACL的mask就一起决定了能否访问。如果没有特定于某个用户,那么文件系统会尝试找有效的组ACL项;如果还没有匹配项,那么在用other::这个ACL项。
3. 如果在一个有ACL的文件上,用chmod来控制组的访问权限,那么修改只对mask有影响。
$ getfacl --omit-header example
user::r--
user:squid:rw-
group::r--
group:squid:rw-
mask::rw-
other::---
$ ls -l example
-r--rw----+ eric eric Dec : example
$ chmod example
$ ls -l example
-rwxrwx---+ eric eric Dec : example
$ getfacl --omit-header example
user::rwx
user:squid:rw-
group::r--
group:squid:rw-
mask::rwx
other::---
这里的ls输出有点误导性。尽管表面上看给组权限,但是没有人因为是组成员而有权执行该文件,为了让组有这样的权限,必须用setfacl编辑ACL本上。
Linux下的ACL的更多相关文章
- linux下通过acl配置灵活目录文件权限(可用于ftp,web服务器的用户权限控制)
linux下通过acl配置灵活目录文件权限(可用于ftp,web服务器的用户权限控制) 发表于2012//07由feng linux 本身的ugo rwx的权限,对于精确的权限控制很是力不从心的,ac ...
- Shell初学(八)linux下的ACL
[1]ACL的作用 简单直接解释一下ACL的作用,即把权限的个别化额外添加. 可以解决如下问题~~比如: [1.1]基于用户: 我有10个用户a1-a10,我有一个文件夹/tmp/test,我想给a1 ...
- 构建LINUX下的入侵检测系统——LIDS 系统管理命令--vlock
构建LINUX下的入侵检测系统——LIDS 系统管理命令--vlock http://blog.chinaunix.net/uid-306663-id-2440200.html LIDS官方网站: ...
- Linux下Nagios的安装与配置
一.本文说明 本文是在参考:http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html David_Tang文章以及网上的一些资料完 ...
- linux下恢复误删除的文件方法(ext2及ext3)
linux下恢复误删除的文件方法(ext2及ext3) 2009-12-19 15:23:47 分类: LINUX 如果是ext2文件系统的,直接用debugfs是可以恢复出来的,但对于ext3,d ...
- Linux下部署Symfony2对app/cache和app/logs目录的权限设置
在linux下部署完Symfony2,可能在访问的时候会报app/logs或者app/cache目录没有写权限的错误.在linux下,如果我们在命令行登陆的用户和web应用服务器(apache.ngi ...
- Linux UGO和ACL权限管理
自主访问控制(Discretionary Access Control, DAC)是指对象(比如程序.文件.进程)的拥有者可以任意修改或者授予此对象相应的权限.Linux的UGO(User, Grou ...
- linux下添加删除,修改,查看用户和用户组
一.组操作 1.创建组: groupadd test #增加一个test组 2.修改组 groupmod -n test2 test #将test组的名子改成test2 3.删除组 groupdel ...
- linux下磁盘相关工具(待整理)
一.概述: fsck tune2fs mke2fs badblocks mkfs* fdisk mount umount mknod e2label blkid hdparm mkswap swapo ...
随机推荐
- spring-mvc.xml的定时器配置
<!-- 设置时间 --> <bean id="myJobTrigger" class="org.springframework.scheduling. ...
- 总结 Date 2017.09.23
总结 Date 2017.09.23 <1>统计数字 某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*10^9).已知不相同的数不超过10000个,现在需要统计 ...
- Highest Tower 18中南多校第一场H题
一.题意 给出N个方块,要求给出一个方案,使得1. 所有方块都被使用到(题目数据保证这点) 2.所有方块垒成一个塔,且上面的方块宽度小于下面的方块 3.每个方块只能用一次,可以横着或者竖着. n范围5 ...
- Android面试收集录15 Android Bitmap压缩策略
一.为什么Bitmap需要高效加载? 现在的高清大图,动辄就要好几M,而Android对单个应用所施加的内存限制,只有小几十M,如16M,这导致加载Bitmap的时候很容易出现内存溢出.如下异常信息, ...
- 12 KLT算法
1 去除多余模块的 #-*- coding:utf-8 -*- ''' Lucas-Kanade tracker ==================== Lucas-Kanade sparse op ...
- P1800 software_NOI导刊2010提高(06)(二分答案)
P1800 software_NOI导刊2010提高(06) 题目描述 一个软件开发公司同时要开发两个软件,并且要同时交付给用户,现在公司为了尽快完成这一任务,将每个软件划分成m个模块,由公司里的技术 ...
- imageX.exe
imageX 编辑ImageX 是一个命令行工具,原始设备制造商 (OEM) 和公司可以使用它来捕获.修改和应用基于文件的磁盘映像以进行快速部署.ImageX 可以使用 Windows 映像 (.wi ...
- 树莓派Raspberry Pi 3安装步骤
一.需要的硬件 1.Raspberry Pi 3(Model B+)树莓派.购买>https://item.jd.com/29225467867.html 2.输出5V/2A的电源 3.SD卡( ...
- python学习笔记三:函数及变量作用域
一.定义 def functionName([arg1,arg2,...]): code 二.示例 #!/usr/bin/python #coding:utf8 #coding=utf8 #encod ...
- windows 下开发的 .netCore MVC 部署到 Linux(Mint)
这两天在公司跟同事偶然聊到 .netCore,说到一些趋势什么的.但是说来说去自己也没试过在Linux 机子上部署过,所以就试一下. 尝试之前也在网上看了一些文章,包括 Linux 上.netCore ...