linux 网络acl,Linux学习之ACL 的使用

ACL主要针对使用者,群组,默认属性。

一、开启ACL

[root@lyy ~]# mount -o remount,acl /home  开启

[root@lyy ~]# mount           查看

/dev/hda2 on / type ext3 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/hda5 on /home type ext3 (rw,usrquota,grpquota,acl)  开启文件系统ACL

/dev/hda1 on /boot type ext3 (rw)

让系统开机就自动开启 可以编辑 /etc/fstab 在defaults 后面加上acl

LABEL=/home         /home           ext3    defaults,acl       1 2

其实在RHEL5.x中安装系统时建立的分区默认已支持ACL,如果是安装好系统后,建立的分区,则需要加

以上述的参数。

ACL的设定技巧: getfacl, setfacl

getfacl:取得某个档案/目录的ACL设定项目。

setfacl:设定某个档案/目录的ACL规则。

setfacl 指令用法:

-m 设定后续的acl参数给档案使用,不可与-x合用

-x 删除后续参数

-b 删除所acl设定参数

-k 移除预设acl参数

-R 递归设定,包括次目录都会设定起来

-d 预设acl参数,只对目录效

二、例:使用setacl 测试 acl_test 给用户pcca 读写权限

[root@lyy test]# touch acltest  建立文件

[root@lyy test]# ll acltest

-rw-r--r-- 1 root root 0 12-07 20:28 acltest

[root@lyy test]# setfacl -m u:pcca:rw acltest   设定pcca拥有读写权限

[root@lyy test]# ll

总计 4

-rw-rw-r--+ 1 root root 0 12-07 20:28 acltest

通过ll来查看,发现权限里多了个+

简单使用 setfacl -m u:使用者:权限 就可以设定权限了。

三、查看权限 getfacl

[root@lyy test]# getfacl acltest

# file: acltest      说明

# owner: root  拥有者

# group: root  所属群组

user::rw-  使用者列表是空的,代表拥有者的权限

user:pcca:rw-  针对pcca授权读写

group::r--  组

mask::rw-   预设有效权限

other::r--  其他人

mask:使用者和群组所设定的权限必须在mask范围内才有效。

预设下,acl不会被次目录所继承,要继承使用参数d

例:

[root@lyy tmp]# setfacl -m g:pc:rwx test

[root@lyy tmp]# cd test

[root@lyy test]# mkdir group

[root@lyy test]# ll group/ -d

drwxr-xr-x 2 root root 4096 12-07 20:47 group/

使用d参数让次目录继承

[root@lyy test]# setfacl -m d:g:pc:rwx ./test/

[root@lyy test]# ll -d

drwxr-xr-x 3 root root 4096 12-07 20:51 .

[root@lyy test]# ll test -d

drwxr-xr-x+ 2 root root 4096 12-07 20:51 test

[root@lyy test]# cd test

[root@lyy test]# mkdir baidu

[root@lyy test]# ll

总计 8

drwxrwxr-x+ 2 root root 4096 12-07 20:52 baidu

命令格式: setfacl -m d:u:使用者:权限

四、取消ACL

命令: setfacl -b 档名

例:

[root@lyy test]# setfacl -b test/          取消ACL

[root@lyy test]# ll

drwxr-xr-x  3 root root 4096 12-07 20:52 test   出现没有+

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值