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
  • 相关阅读:
    day5模块
    day5时间复杂度
    day5冒泡排序
    day4正则表达式
    C语言 经典编程100题
    C语言 第八章 函数、指针与宏
    C语言 第七章 数组与字符串
    C语言 第六章 多重循环
    C语言 第五章 循环结构
    C语言 第四章 分支结构练习
  • 原文地址:https://www.cnblogs.com/zq6041/p/6979104.html
Copyright © 2011-2022 走看看