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

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

[日期:2013-03-19] 来源:Linux社区  作者:sunshyfangtian [字体:大 中 小]
二、ACL权限设置
 
 
 
对文件或者目录具体设置ACL功能以及查看具体的ACL配置,
 
用到setfacel 和getfacl两个命令。
 
下面进行ACL权限设置实验。
 
 
 
准备工作
 
先创建三个普通用户sqa、sqb、sqc及用户组admins,并将用户sqa、sqb加入到该用户组;
 
在/下创建待测试的文件夹dirtesta及其子文件。
 
[root@itpro ~]# useradd sqa
 
[root@itpro ~]# useradd sqb
 
[root@itpro ~]# useradd sqc
 
[root@itpro ~]# groupadd admins
 
[root@itpro ~]# usermod -G admins sqa
 
[root@itpro ~]# usermod -G admins sqb
 
[root@itpro ~]# mkdir /dirtest
 
[root@itpro ~]# touch /dirtest/t01
 
[root@itpro ~]# ll -d /dirtest/
 
drwxr-xr-x. 2 root root 4096 Mar 12 01:08 /dirtest/
 
[root@itpro ~]# ll /dirtest/
 
total 4
 
-rw-r--r--. 1 root root  17 Mar  5 07:04 t01
 
 
 
 
 
实验一
 
求要:其他用户对文件夹dirtest有读写权限,但用户sqa没有任何权限
 
解决方法:给ugo中的o开放读写权限,使用acl限制特定用户sqa
 
 
 
1.先查看当前dirtest的acl
 
[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
 
[root@itpro ~]# ll -d /dirtest/
 
drwxr-xr-x. 2 root root 4096 Mar 12 01:08 /dirtest/
 
 
 
2.更改dirtest的访问权限
 
[root@itpro ~]# chmod o+w /dirtest/
 
(注:给其他用户增加“写”权限)
 
[root@itpro ~]# setfacl -m u:sqa:--- /dirtest/
 
(注:不给用户sqa任何权限)
 
 
 
3.再次查看当前的dirtest权限
 
[root@itpro ~]# getfacl /dirtest/
 
getfacl: Removing leading '/' from absolute path names
 
# file: dirtest/
 
# owner: root
 
# group: root
 
user::rwx
 
user:sqa:---
 
group::r-x
 
mask::r-x
 
other::rwx
 
[root@itpro ~]# ll -d /dirtest/
 
drwxr-xrwx+ 2 root root 4096 Mar 12 01:08 /dirtest/
 
(注:drwxr-xrwx+,这里仍然是按ugo权限排序,最后的“+”,表示设置了acl)
 
 
 
4.测试
 
切换到用户sqa
 
[root@itpro ~]# su sqa
 
[sqa@itpro root]$ ls /dirtest/
 
ls: cannot open directory /dirtest/: Permission denied
 
[sqa@itpro root]$ cd /dirtest/
 
bash: cd: /dirtest/: Permission denied
 
 
 
切换到用户sqb
 
[sqa@itpro root]$ exit
 
exit
 
[root@itpro ~]# su sqb
 
[sqb@itpro root]$ ls /dirtest/
 
t01
 
[sqb@itpro root]$ cd /dirtest/
 
[sqb@itpro dirtest]$ touch t02
 
[sqb@itpro root]$ ls /dirtest/
 
t01  t02
 
 
 
切换回root用户
 
[sqb@itpro root]$ exit
 
exit
 
[root@itpro ~]#linux
相关资讯       ACL权限  Linux基本知识点总结 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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