手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux基本知识点总结——ACL权限设置

[日期:2013-03-19] 来源:Linux社区  作者:sunshyfangtian [字体:大 中 小]
3.对用户sqb设置acl,使其对dirtest具有rwx权限

[root@itpro ~]# setfacl -m u:sqb:rwx /dirtest/

[root@itpro ~]# getfacl /dirtest/

getfacl: Removing leading '/' from absolute path names

# file: dirtest/

# owner: root

# group: root

user::rwx

user:sqb:rwx

group::r-x

group:admins:r-x

mask::rwx

other::rwx

[root@itpro ~]# ll -d /dirtest/

drwxrwxrwx+ 2 root root 4096 Mar 12 01:37 /dirtest/

(注:drwxrwxrwx+,这里不是按ugo权限排序,第一组rwx是文件所有者root的权限,第二组rwx是用户sqb的权限,第三组rwx是其他用户的权限,“+”表示acl设置的权限。

如果将其他用户的权限改回默认的r-x,会更易理解,如:

[root@itpro ~]# chmod o-w /dirtest/

[root@itpro ~]# ll -d /dirtest/

drwxrwxr-x+ 2 root root 4096 Mar 12 01:37 /dirtest/

)



4.测试

依次切换到用户sqa、sqb、sqc,查看其对dirtest文件夹的操作权限,

[root@itpro ~]# su sqa

[sqa@itpro root]$ ls /dirtest/

t01 t02

[sqa@itpro root]$ touch /dirtest/t03

touch: cannot touch `/dirtest/t03': Permission denied

[sqa@itpro root]$ exit

exit

[root@itpro ~]# su sqb

[sqb@itpro root]$ ls /dirtest/

t01 t02

[sqb@itpro root]$ touch /dirtest/t03

[sqb@itpro root]$ ls /dirtest/

t01 t02 t03

[sqb@itpro root]$ exit

exit

[root@itpro ~]# su sqc

[sqc@itpro root]$ ls /dirtest/

t01 t02 t03

[sqc@itpro root]$ touch /dirtest/t04

[sqc@itpro root]$ ls /dirtest/

t01 t02 t03 t04

[sqc@itpro root]$ ll /dirtest/

total 8

-rw-r--r--. 1 root root 17 Mar 5 07:04 t01

-rw-rw-r--. 1 sqb sqb 0 Mar 12 01:37 t02

-rw-rw-r--. 1 sqb sqb 0 Mar 12 02:22 t03

-rw-rw-r--. 1 sqc sqc 0 Mar 12 02:24 t04

[sqc@itpro root]$ exit

exit

(注:由于sqc不在用户组admins,所在sqc的权限为其他用户(ugo中的o)的权限,即rwx(实验一中设置的))



至此,实验结束,如果要恢复dirtest的访问权限为实验前的权限,可进行以下操作:

[root@itpro ~]# setfacl -b /dirtest/

(注:-b选项,表示清除指定对象的所有acl设置,慎用)

[root@itpro ~]# chmod o-w /dirtest/

(注:other的权限也改回r-x)

[root@itpro ~]# ll -d /dirtest/

drwxr-xr-x. 2 root root 4096 Mar 12 02:24 /dirtest/

[root@itpro ~]# getfacl /dirtest/

getfacl: Removing leading '/' from absolute path names

# file: dirtest/

# owner: root

# group: root

user::rwx

group::r-x

other::r-x

(注:可以看到,此时的文件权限恢复到常规状态)linux
相关资讯       ACL权限  Linux基本知识点总结 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款