linux下的acl权限使用

#

#创建文件

#

[root@pc f]# cd tmp/testacl
[root@pc testacl]# ls
[root@pc testacl]# touch f1
[root@pc testacl]# echo "aaa" >f1
[root@pc testacl]# cat f1
aaa

#

#创建用户

#

[root@pc testacl]# useradd usr1
[root@pc testacl]# passwd usr1
[root@pc testacl]# useradd usr2
[root@pc testacl]# passwd usr2
[root@pc testacl]# useradd usr3
[root@pc testacl]# passwd usr3

#

#创建文件

#
[root@pc testacl]# ll f1
-rw-r--r-- 1 root root 4 2009-03-06 10:00 f1
[root@pc testacl]# chmod 600 f1
[root@pc testacl]# ll f1
-rw------- 1 root root 4 2009-03-06 10:00 f1
 
[root@pc testacl]# setfacl -m u:usr1:r f1
[root@pc testacl]# setfacl -m u:usr2:rw f1
[root@pc testacl]# su usr1
[usr1@pc testacl]$ cat f1
aaa
[usr1@pc testacl]$ echo "bbb" >>f1
bash: f1: Permission denied
 
[usr1@pc testacl]$ su usr2
Password:
[usr2@pc testacl]$ cat f1
aaa
[usr2@pc testacl]$ echo "bbb" >>f1
[usr2@pc testacl]$ cat f1
aaa
bbb
[usr2@pc testacl]$ exit
exit
[usr1@pc testacl]$ exit
exit
 
[root@pc testacl]# getfacl f1
# file: f1
# owner: root
# group: root
user::rw-
user:usr1:r--
user:usr2:rw-
group::---
mask::rw-
other::---
 
[root@pc testacl]# su usr3
[usr3@pc testacl]$ cat f1
cat: f1: Permission denied
[usr3@pc testacl]$ exit
exit
 
[root@pc testacl]# setfacl -x u:usr1 f1
[root@pc testacl]# getfacl f1
# file: f1
# owner: root
# group: root
user::rw-
user:usr2:rw-
group::---
mask::rw-
other::---
 
[root@pc testacl]# su usr1
[usr1@pc testacl]$ cat f1
cat: f1: Permission denied
[usr1@pc testacl]$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值