zoukankan      html  css  js  c++  java
  • acl

    [root@zq ~]# touch /tmp/a.txt
    [root@zq ~]# getfacl /tmp/a.txt #查看权限
    getfacl: Removing leading '/' from absolute path names
    # file: tmp/a.txt
    # owner: root
    # group: root
    user::rw-
    group::r--
    other::r--
    
    扩展ACL
    [root@zq ~]# setfacl -m u:zq:rwx /tmp/a.txt   #u:设置某个用户拥有的权限  -m 设置权限
    [root@zq ~]# getfacl !$
    getfacl /tmp/a.txt
    getfacl: Removing leading '/' from absolute path names
    # file: tmp/a.txt
    # owner: root
    # group: root
    user::rw-
    user:zq:rwx
    group::r--
    mask::rwx
    other::r--
    
    [root@zq ~]# setfacl -m g:zq:rwx /tmp/a.txt 
    [root@zq ~]# getfacl /tmp/a.txt
    getfacl: Removing leading '/' from absolute path names
    # file: tmp/a.txt
    # owner: root
    # group: root
    user::rw-
    user:zq:rwx
    group::r--
    group:zq:rwx
    mask::rwx
    other::r--
    
    
    [zq@zq 桌面]$ ll /tmp/a.txt 
    -rw-r--r--. 1 root root 0 6月  10 14:29 /tmp/a.txt
    [zq@zq 桌面]$ ll /tmp/a.txt 
    -rw-rwxr--+ 1 root root 0 6月  10 14:29 /tmp/a.txt
    
    
    [root@zq ~]# mkdir /tmp/test   
    [root@zq ~]# setfacl -R -m u:zq:rw- /tmp/test/    #设置目录acl权限
    [root@zq ~]# get !$
    get /tmp/test/
    -bash: get: command not found
    [root@zq ~]# getfacl !$
    getfacl /tmp/test/
    getfacl: Removing leading '/' from absolute path names
    # file: tmp/test/
    # owner: root
    # group: root
    user::rwx
    user:zq:rw-
    group::r-x
    mask::rwx
    other::r-x
    
    
    取消acl权限
    [root@zq ~]# setfacl -x u:zq:rw- /tmp/test/
    setfacl: Option -x: 无效的参数 near character 6
    [root@zq ~]# setfacl -x u:zq: /tmp/test/
    [root@zq ~]# getfacl !$
    getfacl /tmp/test/
    getfacl: Removing leading '/' from absolute path names
    # file: tmp/test/
    # owner: root
    # group: root
    user::rwx
    group::r-x
    mask::r-x
    other::r-x
    
    取消所有的权限
    [root@zq ~]# setfacl -b /tmp/a.txt 
    [root@zq ~]# getfacl !$
    getfacl /tmp/a.txt
    getfacl: Removing leading '/' from absolute path names
    # file: tmp/a.txt
    # owner: root
    # group: root
    user::rw-
    group::r--
    other::r--
    
    
    创建一个让root都无法删除的黑客文件
    rhel6 Linux文件系统扩展属性:chattr lsattr
    +a    只能追加内容
    +i     不能被修改
    [root@zq ~]# ll a.txt 
    -rwxrwxrwx. 1 root root 13 6月  10 16:13 a.txt
    [root@zq ~]# lsattr a.txt 
    -------------e- a.txt
    [root@zq ~]# chattr +a a.txt 
    [root@zq ~]# echo aaa >> a.txt 
    [root@zq ~]# cat a.txt 
    sdfadsfadsfa
    aaa
    [root@zq ~]# chattr +i a.txt 
    [root@zq ~]# echo bbbb >> a.txt 
    -bash: a.txt: 权限不够
    [root@zq ~]# lsattr a.txt 
    ----ia-------e- a.txt
    [root@zq ~]# rm -rf a.txt 
    rm: 无法删除"a.txt": 不允许的操作
    要想有删除更改内容的权限必须去掉ia
    [root@zq ~]# chattr -ia a.txt 
    [root@zq ~]# lsattr a.txt 
    -------------e- a.txt
  • 相关阅读:
    C++ 课程设计——电梯调度系统
    PAT 1006 Sign In and Sign Out 查找元素
    PAT 1005 Spell It Right 字符串处理
    C++ 词汇表
    四六级分数竟是这样算出来的!交白卷都不会得零分 (转)
    以太坊智能合约部署
    如何设计一个通证经济体系?(转载)
    以太坊上那些暴力“利”的应用(转载)
    geth搭建以太坊私链及常用操作
    ubuntu18.04 安装 QQ
  • 原文地址:https://www.cnblogs.com/zq6041/p/6979104.html
Copyright © 2011-2022 走看看