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

Linux培训笔记之Linux权限详解

[日期:2014-06-04] 来源:Linux社区  作者:Linux [字体:大 中 小]

三、access control lists (ACLs)
1.grant or deny additional access to multiple users or group
2.implemented as a mount option(acl)
  -embedded in filesystem superblock at install time
用chmod更改大权限,用ACL进行微调。

四、managing ACLs
1.viewing:
  -$getfacl filename
2.modifying (adding or changing)
  -$setfacl -m u:gandalf:rw filename  (追加权限)
3.removing(expunging):
  -$setfacl -x u:gandalf filename    (删减权限)


实验二、root用户新建/file文件,权限为640,分配给IT组,frodo,sam和pippin仍为IT成员
1.frodo可以编辑/file文件
2.pippin不可以查看/file
users:        group:
frodo            IT
sam              IT
pippin          IT
/file    root    IT
  rw-    r--    ---
(这样的权限组成员是无法修改该文件,只能查看该文件)
eg:


[root@instructor /]# touch /file
[root@instructor /]# chmod 640 /file
[root@instructor /]# ll /file
-rw-r-----. 1 root root 0 Jan  2 22:45 /file
[root@instructor /]# chgrp IT /file
[root@instructor /]# ll /file
-rw-r-----. 1 root IT 0 Jan  2 22:45 /file
[root@instructor /]# vi /file
secret
~
~
"/file" 2L, 8C written  (root修改了/file文件)
[root@instructor /]# su - frodo
[frodo@instructor ~]$ cat /file  (frodo可以查看该文件内容)
secret

[frodo@instructor ~]$ vim /file  (frodo无法修改该文件内容)
secret

~
~

[frodo@instructor ~]$ cat /file
secret

[frodo@instructor ~]$ su -
Password:
[root@instructor ~]# setfacl -m u:frodo:rw- /file
[root@instructor ~]# su - frodo
[frodo@instructor ~]$ cd ..
[frodo@instructor home]$ cd ..

[frodo@instructor /]$ vim /file
secret
modified by frodo
~
~
"/file" 3L, 26C written  (frodo增加了/file内容:modified by frodo)                                       
[frodo@instructor /]$ su - sam
Password:
[sam@instructor ~]$ cat /file  (sam可以看到文件被frodo修改了)
secret
modified by frodo

[sam@instructor ~]$ vim /file  (sam也想修改,但是readonly)
secret
modified by frodo

~

[sam@instructor ~]$
[sam@instructor ~]$
[sam@instructor ~]$ su - pippin
Password:
[pippin@instructor ~]$ cat /file
secret
modified by frodo

[pippin@instructor ~]$ su -
Password:
[root@instructor ~]# setfacl -m u:pippin:--- /file
[root@instructor ~]# su - pippin
[pippin@instructor ~]$ cat /file
cat: /file: Permission denied
[pippin@instructor ~]$ su -
Password:
[root@instructor ~]# ll
total 31796
-rw-------.  1 root root      965 Aug 24 16:11 anaconda-ks.cfg
drwxr-xr-x.  2 root root    4096 Aug 31 16:26 Desktop
drwxr-xr-x.  2 root root    4096 Aug 24 08:20 Documents
drwxr-xr-x.  2 root root    4096 Aug 24 08:20 Downloads
drwxr-xr-x. 127 root root    12288 Aug 30 11:09 etc
-rw-r--r--.  1 root root 15057753 Aug 30 11:53 etc.tar.bz2
-rw-r--r--.  1 root root 17429237 Aug 30 11:55 etc.tar.gz
drwxr-xr-x.  2 root root    4096 Aug 24 08:20 Music
drwxr-xr-x.  2 root root    4096 Aug 24 08:20 Pictures
-rw-r--r--.  1 root root    11955 Jul  7  2012 post-install
-rw-r--r--.  1 root root      550 Jul  7  2012 post-install.log
drwxr-xr-x.  2 root root    4096 Aug 24 08:20 Public
drwxr-xr-x.  2 root root    4096 Aug 24 08:20 Templates
drwxr-xr-x.  2 root root    4096 Aug 24 08:20 Videos
[root@instructor ~]# cd ..
[root@instructor /]# ll
total 118
dr-xr-xr-x.  2 root  root  4096 Aug 27 11:33 bin
dr-xr-xr-x.  5 root  root  1024 Aug 24 16:11 boot
drwxrws---.  2 root  IT    4096 Jan  2 22:06 corp
drwxr-xr-x.  19 root  root  3920 Jan  2 19:49 dev
drwxr-xr-x. 127 root  root 12288 Jan  2 21:43 etc
-rw-rw----+  1 root  IT      26 Jan  2 22:58 file
drwxr-xr-x.  9 root  root  4096 Jan  2 21:36 home
dr-xr-xr-x.  19 root  root 12288 Sep  4 21:24 lib
drwx------.  2 root  root 16384 Jul  7  2012 lost+found
drwxr-xr-x.  3 root  root  4096 Jan  2 19:51 media
drwxr-xr-x.  2 root  root    0 Jan  2 19:49 misc
drwxr-xr-x.  5 root  root  4096 Aug 30 15:03 mnt
drwxr-xr-x.  2 root  root    0 Jan  2 19:49 net
drwxr-xr-x.  3 root  root  4096 Jul  7  2012 opt
dr-xr-xr-x. 198 root  root    0 Jan  2 19:48 proc
dr-xr-x---.  30 root  root  4096 Jan  2 19:50 root
dr-xr-xr-x.  2 root  root 12288 Sep  2 10:15 sbin
drwxr-xr-x.  7 root  root    0 Jan  2 19:48 selinux
drwx------.  2 tommy root  4096 Sep  4 22:22 smbshare
drwxr-xr-x.  2 root  root  4096 Sep 23  2011 srv
drwxr-xr-x.  13 root  root    0 Jan  2 19:48 sys
drwxrwxrwt.  19 root  root 12288 Jan  2 22:56 tmp
drwxr-xr-x.  12 root  root  4096 Jul  7  2012 usr
drwxr-xr-x.  23 root  root  4096 Aug 28 21:22 var
[root@instructor /]# getfacl /file
getfacl: Removing leading '/' from absolute path names
# file: file
# owner: root
# group: IT
user::rw-
user:pippin:---
user:frodo:rw-
group::r--
mask::rw-
other::---

[root@instructor /]# setfacl -x u:pippin /file
[root@instructor /]# su - pippin
[pippin@instructor ~]$ cat /file
secret
modified by frodo

[pippin@instructor ~]$ su -
Password:
[root@instructor ~]# getfacl /file
getfacl: Removing leading '/' from absolute path names
# file: file
# owner: root
# group: IT
user::rw-
user:frodo:rw-
group::r--
mask::rw-
other::---

五、permission precedence with ACLs
1.compare process UID to
 -UID of file => user permissions apply
  -ACL UID of file => ACL's permissions apply
2.otherwise,compare list of process GIDs to
  -GID of file =>group permissions apply
  -ACL GID of file => ACL's permissions apply
  -since there can be multiple matchers at this level,it is additive within this    level
3.if neither match,other permissions aply

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-06/102673.htm

linux
相关资讯       Linux培训笔记 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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