• 查看系统分区df,查看、设置、修改、删除ACL权限


    df

    [root@localhost ~]# df -h
    文件系统        容量  已用  可用 已用% 挂载点
    /dev/sda5        16G  1.4G   15G    9% /
    devtmpfs        479M     0  479M    0% /dev
    tmpfs           489M     0  489M    0% /dev/shm
    tmpfs           489M  6.7M  482M    2% /run
    tmpfs           489M     0  489M    0% /sys/fs/cgroup
    /dev/sda2       2.0G   33M  2.0G    2% /home
    /dev/sda1       197M  114M   83M   58% /boot
    tmpfs            98M     0   98M    0% /run/user/0
    /dev/sr0        4.1G  4.1G     0  100% /mnt/cdrom

     查看是否支持ACL:dumpe2fs -h /dev/sda5

    临时开启分区ACL权限:mount -o remount,acl /

    永久修改:在/etc/fstab文件中加入acl,见红字:  UUID=70dade4c-e85f-4592-a133-26f1fb359801 /                       xfs     defaults,acl        0 0

    重新挂载文件系统:mount -o remount /


    制作演示相关用户组文件:

    [root@localhost ~]# mkdir project
    [root@localhost ~]# ls
    project
    [root@localhost ~]# ll -d project/
    drwxr-xr-x. 2 root root 6 8月   5 19:22 project/
    [root@localhost ~]# groupadd testgroup
    [root@localhost ~]# gpasswd -a xiongjiawei testgroup
    正在将用户“xiongjiawei”加入到“testgroup”组中
    [root@localhost ~]# gpasswd -a qiaofeng testgroup   
    正在将用户“qiaofeng”加入到“testgroup”组中
    [root@localhost ~]# grep testgroup /etc/group
    testgroup:x:1003:xiongjiawei,qiaofeng
    [root@localhost ~]# chown root:testgroup /root/project
    [root@localhost ~]# chmod 770 /root/project
    [root@localhost ~]# ll -d /root/project/
    drwxrwx---. 2 root testgroup 6 8月   5 19:22 /root/project/
    [root@localhost ~]# useradd st
    [root@localhost ~]# passwd st
    更改用户 st 的密码 。
    新的 密码:
    无效的密码: 密码少于 8 个字符
    重新输入新的 密码:
    passwd:所有的身份验证令牌已经成功更新。
    [root@localhost ~]# setfacl -m u:st:rx /root/project
    [root@localhost ~]# ll -d /root/project/
    drwxrwx---+ 2 root testgroup 6 8月   5 19:22 /root/project/
    [root@localhost ~]# getfacl /root/project/
    getfacl: Removing leading '/' from absolute path names
    # file: root/project/
    # owner: root
    # group: testgroup
    user::rwx
    user:st:r-x
    group::rwx
    mask::rwx
    other::---
    [root@localhost ~]# su - st
    上一次登录:六 8月  5 19:34:07 CST 2017pts/0 上
    [st@localhost ~]$ cd /root/project/
    [st@localhost project]$ ls
    [st@localhost project]$ touch file
    touch: 无法创建"file": 权限不够
    [st@localhost project]$ 
    [root@localhost ~]# su - yangguo
    [yangguo@localhost ~]$ cd /root/project
    -bash: cd: /root/project: 权限不够

    setfacl -m g:组名:rwx 文件或目录名

    查看、更改最大ACL权限:

    [root@localhost ~]# setfacl -m m:rx /root/project/
    [root@localhost ~]# getfacl /root/project/        
    getfacl: Removing leading '/' from absolute path names
    # file: root/project/
    # owner: root
    # group: testgroup
    user::rwx
    user:st:r-x
    group::rwx                      #effective:r-x
    mask::r-x     注:mask即为最大有效权限,实际赋值权限要和mask相与后得到的权限才是最终有效权限
    other::---

     删除ACL权限:

    setfacl -x u:用户名 文件名  :删除文件下指定用户的ACL权限

    setfacl -x g:组名 文件名  :删除文件下指定组的ACL权限

    setfacl -b 文件名  :删除整个文件下所有ACL权限

    递归ACL权限:setfacl -m u:用户名:权限 -R 目录   注:只对目录中已有文件有效,后建文件无效

    默认ACL权限:setfacl -m d:u:用户名:权限 目录  注:只对目录后建文件有效,已有文件无效

  • 相关阅读:
    integer比较
    String比较
    StringBuffer的s1.capacity()是多少?
    时间复杂度
    京东面试--总结
    说下Java堆空间结构,及常用的jvm内存分析命令和工具
    linux下jmap,jstat和jstack使用
    jvm 性能调优工具之 jmap
    jstack(查看线程)、jmap(查看内存)和jstat(性能分析)命令
    android小技巧:在activity中实现与绑定的fragment的回调
  • 原文地址:https://www.cnblogs.com/xiongjiawei/p/7291109.html
Copyright © 2020-2023  润新知