测试acl

来源:互联网 发布:金蝶软件明细账查找 编辑:程序博客网 时间:2024/05/21 00:17

环境:存储ip为172.19.61.178,linux客户端ip为172.19.61.105

存储端

在/share/nas中建立文件 123.txt,  echo "test" >123.txt
查看属性getfacl 123.txt
root:/share/nas# getfacl  123.txt
# file: 123.txt
# owner: root
# group: root
user::rw-
group::r--
other::r--      //其他用户只能读

linux客户端

mount -t nfs 172.19.61.178:/share/nas    /mnt
[root@chen mnt]# ls
123.txt
在linux中,建立一个用户user0,以user0来登录,则user0是不写数据到文件123.txt中
[user0@chen mnt]$ echo  "user0"  >>123.txt
bash: 123.txt: 权限不够
[user0@chen mnt]$ cat 123.txt
test

在存储端设置文件属性
root:/share/nas# setfacl  -m other:rwx   123.txt
root:/share/nas# getfacl  123.txt
# file: 123.txt
# owner: root
# group: root
user::rw-
group::r--
other::rwx
在linux客户端,[user0@chen mnt]$ echo  "user0"  >>123.txt,
这样权限设置范围太广了,对user0单独设置权限
在存储端 建立用户user0(和linux客户端user0的id号相同)
设置对user0用户的权限
setfacl   -m  user:user0:rwx  123.txt