1.查看acl命令

getfacl 文件名     #查看acl权限

2.设定acl权限命令

setfacl 选项 文件名
选项: -m 设置ACL权限 -x 删除指定的ACL权限 -b 删除所有的ACL设定权限 -R 递归设置ACL权限 -d 设置默认的ACL权限(只对目录有效,在该目录新建的文件也会使用此 ACL默认值) -k 删除默认的ACL权限

2.1添加用户acl权限

[root@localhost ~]# mkdir /test                   #创建test目录
[root@localhost ~]# ll -d /test                   #查看test目录文件详细信息
drwxr-xr-x. root root 4月 : /test
[root@localhost ~]# useradd test1                  #创建test1用户
[root@localhost ~]# useradd test2                  #创建test2用户
[root@localhost ~]# groupadd testgroup               #创建testgroup组
[root@localhost ~]# gpasswd -a test1 testgroup          #将test1用户添加到testgroup组
正在将用户“test1”加入到“testgroup”组中
[root@localhost ~]# gpasswd -a test2 testgroup          #将test2添加到testgroup组
正在将用户“test2”加入到“testgroup”组中
[root@localhost ~]# cat /etc/group                 #查看group文件testgroup组用户

[root@localhost ~]# chown root:testgroup /test          #修改test目录身份
 [root@localhost ~]# chmod 770 /test                 #修改test目录权限
 [root@localhost ~]# ll -d /test#查看test详细信息
 drwxrwx---. 2 root testgroup 6 4月 16 09:37 /test

[root@localhost ~]# useradd test                  #添加一个额外的用户,对test目录不同的权限操作
 [root@localhost ~]# passwd test                   #添加用户密码
 更改用户 test 的密码 。
 新的 密码:
 无效的密码: 密码少于 8 个字符
 重新输入新的 密码:
 passwd:所有的身份验证令牌已经成功更新。
 [root@localhost ~]# setfacl -m u:test:rx /test          #设置test文件acl全权限

 [root@localhost ~]# ll -d /test
 drwxrwx---+ 2 root testgroup 6 4月 16 09:37 /test              #test目录权限多了个加号,说明有acl权限了

 [root@localhost ~]# getfacl /test                        #查看目录acl具体信息

 getfacl: Removing leading '/' from absolute path names
 # file: test
 # owner: root
 # group: testgroup
 user::rwx
 user:test:r-x                                   #test用户拥有了test目录读和执行权限
 group::rwx
 mask::rwx
 other::---

[root@localhost ~]# su test                          #切换test用户
[test@localhost root]$ cd /test                        #test用户可以进入
[test@localhost test]$ touch a                        #test用户不能创建
touch: 无法创建"a": 权限不够

 

2.2添加组acl权限

[root@localhost test]# groupadd testgroup1           #添加testgroup1组
[root@localhost test]# setfacl -m g:testgroup1:rwx /test  #设置test目录acl testgroup组权限
[root@localhost test]# getfacl /test              #查看test目录acl权限
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: testgroup
user::rwx
user:test:r-x
group::rwx
group:testgroup1:rwx                        #test目录拥有了testgroup1组额外rwx权限
mask::rwx
other::---

3.设置最大有效权限

在设置完acl时,查看都能看到倒数第二行有个mask项,这个mask是对acl权限的一个限定的。也就是说acl的设定权限不一定是真正的有效权限,

是需要和mask相与“”才是真的有效权限。

来个例子:

[root@localhost ~]# setfacl -m m:rw /test      #给test目录设置最大有效权限
[root@localhost ~]# getfacl /test           #查看test目录acl权限
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: testgroup
user::rwx
user:test:r-x #effective:r--   #test用户acl有效权限是r--
group::rwx #effective:rw-  #所属组有效权限是rw-
group:testgroup1:rwx #effective:rw-  #testgroup1有效acl权限rw-
mask::rw-
other::---

mask权限的设定不影响所有者的权限。默认不写的话,mask权限是rwx

4.删除ACL权限

删除acl权限命令:

setfacl -x 用户或组 文件名
[root@localhost ~]# setfacl -x g:testgroup1 /tes#删除testgroup1的acl权限
[root@localhost ~]# getfacl /test #查看test目录acl权限
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: testgroup
user::rwx
user:test:r-x
group::rwx
mask::rwx
other::---

testgroup1组的acl权限已经没了。

也可以一次性删除目录下所有acl权限

setfacl -d 文件名
[root@localhost ~]# setfacl -b /test     #删除test目录所有acl权限
[root@localhost ~]# getfacl /test
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: testgroup
user::rwx
group::rwx
other::---

5.递归ACL权限

有时候希望目录下面子文件或子文件夹使用父目录的acl权限,而不是每次都手动设置acl命令。递归ACL就是完成这个操作

命令:

setfacl -R 文件名          #该命令只能针对目录及子目录操作

[root@localhost ~]# setfacl -m u:test:rw /test       #先不用递归设置test目录acl权限 
  [root@localhost ~]# getfacl /test
  getfacl: Removing leading '/' from absolute path names
  # file: test
  # owner: root
  # group: testgroup
  user::rwx
  user:test:rw-
  group::rwx
  mask::rwx
  other::---

[root@localhost ~]# cd /test                      #test目录下创建的a,b文件为没有acl权限的
[root@localhost test]# touch a
[root@localhost test]# touch b
[root@localhost test]# ll
总用量
-rw-r--r--. root root 4月 : a
-rw-r--r--. root root 4月 : b
[root@localhost test]# setfacl -m u:test:rw -R /test      #使用递归设置test目录acl权限
[root@localhost test]# getfacl /test
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: testgroup
user::rwx
user:test:rw-
group::rwx
mask::rwx
other::--- [root@localhost test]# ll
总用量
-rw-rw-r--+ root root 4月 : a              #a文件已经有acl权限了
-rw-rw-r--+ root root 4月 : b

注意一点:递归设置acl文件只能对现有的文件实现,后面新建的文件是没有acl权限的。如果你想后面新建文件也能实现acl权限,就是后面的默认acl权限了

6.默认ACL权限

命令:

setfacl -m d: u:用户名:权限 文件名              #该命令只能目录有效
[root@localhost test]# setfacl -m d:u:test:rw -R /test
[root@localhost test]# touch c
[root@localhost test]# ll
总用量
-rw-rw-r--+ root root 4月 : a
-rw-rw-r--+ root root 4月 : b
-rw-rw----+ root root 4月 : c        #后面c文件也有了acl权限

                                                                                                          2019-04-16

acl权限命令的更多相关文章

  1. LInux ACL权限控制

    1.ACL简介 ACL是一种可以实现灵活的权限管理(文件的额外赋权机制)除了文件所有者,所属组和其他人,可以对更多的用户设置权限,这就是访问控制列表(Access Control List) 2.AC ...

  2. ACL权限设置命令setfacl和getfacl命令

    ACL权限设置命令setfacl和getfacl命令 setfacl命令是用来在命令行里设置ACL(访问控制列表).在命令行里,一系列的命令跟随以一系列的文件名. [TOC] 选项 |参数|说明|   ...

  3. Linux下ACL权限控制以及用sudo设置用户对命令的执行权限

    ACL权限分配 1.setfacl命令设置文件权限 setfacl -m u:user1:rw root.txt setfacl -m u:user2:rwx root.txt 2.getfacl命令 ...

  4. linux ACL权限规划:getfacl,setfacl使用

    ACL即Access Control List 主要的目的是提供传统的owner,group,others的read,write,execute权限之外的具体权限设置,ACL可以针对单一用户.单一文件 ...

  5. <实训|第十三天>linux中ACL权限控制以及磁盘配额,附编译属于自己的linux内核

    [root@localhost~]#序言 首先讲讲昨天关于缩容失败,开不机的解决方法:ACL权限也算是一个很重要的知识点,不难,但是很实用:磁盘配额一般不需要自己弄,但是要懂得原理.剩下的就是编译属于 ...

  6. 五大权限:UGO权限、SetUID SetGID Sticky、ACL权限、chattr(文件系统级别的权限)、SELINUX

    五大权限:UGO权限.SetUID SetGID Sticky.ACL权限.chattr(文件系统级别的权限).SELINUX   ======================文件属性以及ugo权限= ...

  7. linux:ACL权限

    ACL权限是为了防止权限不够用的情况,一般的权限有所有者.所属组.其他人这三种,当这三种满足不了我们的需求的时候就可以使用ACL权限: 比如:一个网络老师,给一个班的学员上课,他在linux的根目录下 ...

  8. Linux UGO和ACL权限管理

    自主访问控制(Discretionary Access Control, DAC)是指对象(比如程序.文件.进程)的拥有者可以任意修改或者授予此对象相应的权限.Linux的UGO(User, Grou ...

  9. Linux系列教程(十六)——Linux权限管理之ACL权限

    通过前面的两篇博客我们介绍了Linux系统的用户管理,Linux用户和用户组管理之相关配置文件 讲解了用户管理的相关配置文件,包括用户信息文件/etc/passwd,用户密码文件/etc/shadow ...

随机推荐

  1. luogu P5304 [GXOI/GZOI2019]旅行者

    传送门 所以这个\(5s\)是SMG 暴力是枚举每一个点跑最短路,然后有一个很拿衣服幼稚的想法,就是把所有给出的关键点当出发点,都丢到队列里,求最短路的时候如果当前点\(x\)某个相邻的点\(y\)是 ...

  2. 【汇编语言】DOXBox 0.74 常用debug命令

    1.查看.修改寄存器(r命令) ①-r ②-r  ax(要修改的寄存器) -:m(输入想要改成什么值) 2.查看内存单元(d命令) ①-d 查看128个内存单元内容. ②-d 段地址:偏移地址 查看指 ...

  3. 机器学习用Pandas实现数据库的读取

    #读取数据库数据#import pandas as pd  导入模块#import pymysql  导入数据库模块#con = pymysql.connect(host='localhost',po ...

  4. monkey日志解析

    bash arg: -p (打印monkey命令携带的参数) bash arg: com.dapp.testAPP123 bash arg: --throttle bash arg: 200 bash ...

  5. 分享一个VueCli 3.0的项目模板

    个人搭建的Vue项目模板 默认自带  Vuex  Less 封装内容如下 vue.config axios 封装 vue 配置环境文件 vue 自定义路径映射 (cli3.0取消了默认@ 映射src的 ...

  6. Appnium-API-Dvice

    Device Activity Start Activity Start an Android activity by providing package name and activity name ...

  7. 项目Alpha冲刺(团队)-第五天冲刺

    格式描述 课程名称:软件工程1916|W(福州大学) 作业要求:项目Alpha冲刺(团队)-代码规范.冲刺任务与计划 团队名称:为了交项目干杯 作业目标:描述第五天冲刺的项目进展.问题困难.心得体会 ...

  8. WebApi-2 自定义路由与默认路由

    向Web API添加路由 public static void Register(HttpConfiguration config) { //// Web API 配置和服务 //// 将 Web A ...

  9. 如何用java实现一个p2p种子搜索(1)-概念

    前言 说句大实话,网上介绍怎么用java实现p2p种子的搜索这种资料不是特别多,大部分都是python的,用python的话就会简单很多,它里面有很多简单方便的包,libtorrent等等,当然你用这 ...

  10. Kali Linux的vi编辑器/vim编辑器使用方法

    转载声明:本文为转载文章 原文地址:https://www.52host.cn/blog/kali-linux-vi-editor/ Kali Linux系统的vi编辑器/vim编辑器的使用和Cent ...