权限管理-ACL
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
1 [root@yinzhengjie ~]# df -h 2 Filesystem Size Used Avail Use% Mounted on 3 /dev/sda2 18G 2.8G 14G 17% / 4 tmpfs 491M 224K 491M 1% /dev/shm 5 /dev/sda1 283M 28M 240M 11% /boot 6 [root@yinzhengjie ~]# 7 [root@yinzhengjie ~]# 8 [root@yinzhengjie ~]# 9 [root@yinzhengjie ~]# dumpe2fs -h /dev/sda2 | grep "Default mount options" 10 dumpe2fs 1.41.12 (17-May-2010) 11 Default mount options: user_xattr acl 12 [root@yinzhengjie ~]#
1 [root@yinzhengjie ~]# mkdir /yinzhengjie/
2 [root@yinzhengjie ~]# useradd canglaoshi
3 [root@yinzhengjie ~]# useradd jichimingbu
4 [root@yinzhengjie ~]# groupadd AVgroup
5 [root@yinzhengjie ~]# gpasswd -a canglaoshi AVgroup
6 Adding user canglaoshi to group AVgroup
7 [root@yinzhengjie ~]# gpasswd -a jichimingbu AVgroup
8 Adding user jichimingbu to group AVgroup
9 [root@yinzhengjie ~]#
10 [root@yinzhengjie ~]# tail -1 /etc/group
11 AVgroup:x:504:canglaoshi,jichimingbu
12 [root@yinzhengjie ~]#
13 [root@yinzhengjie ~]# chown root:AVgroup /yinzhengjie/
14 [root@yinzhengjie ~]# chmod 770 /yinzhengjie/
15 [root@yinzhengjie ~]# ll -d /yinzhengjie/
16 drwxrwx---. 4 root AVgroup 4096 9月 28 12:56 /yinzhengjie/
17 [root@yinzhengjie ~]#
18 [root@yinzhengjie ~]#
19 [root@yinzhengjie ~]# useradd yangmi
20 [root@yinzhengjie ~]# echo "123456" | passwd --stdin yangmi
21 更改用户 yangmi 的密码 。
22 passwd: 所有的身份验证令牌已经成功更新。
23 [root@yinzhengjie ~]#
24 [root@yinzhengjie ~]# setfacl -m u:yangmi:rx /yinzhengjie/
25 [root@yinzhengjie ~]#
26 [root@yinzhengjie ~]# getfacl /yinzhengjie/
27 getfacl: Removing leading ‘/‘ from absolute path names
28 # file: yinzhengjie/
29 # owner: root
30 # group: AVgroup
31 user::rwx
32 user:yangmi:r-x
33 group::rwx
34 mask::rwx
35 other::---
36
37 [root@yinzhengjie ~]#
38 [root@yinzhengjie ~]# ll -d /yinzhengjie/
39 drwxrwx---+ 4 root AVgroup 4096 9月 28 12:56 /yinzhengjie/
40 [root@yinzhengjie ~]#
41 [root@yinzhengjie ~]# su yangmi
42 [yangmi@yinzhengjie root]$
43 [yangmi@yinzhengjie root]$ cd /yinzhengjie/
44 [yangmi@yinzhengjie yinzhengjie]$ ls
45 golang postfix
46 [yangmi@yinzhengjie yinzhengjie]$ touch {1..5}.txt
47 touch: 无法创建"1.txt": 权限不够
48 touch: 无法创建"2.txt": 权限不够
49 touch: 无法创建"3.txt": 权限不够
50 touch: 无法创建"4.txt": 权限不够
51 touch: 无法创建"5.txt": 权限不够
52 [yangmi@yinzhengjie yinzhengjie]$
1 [root@yinzhengjie ~]# setfacl -x g:movie /yinzhengjie/
2 [root@yinzhengjie ~]# getfacl /yinzhengjie/
3 getfacl: Removing leading ‘/‘ from absolute path names
4 # file: yinzhengjie/
5 # owner: root
6 # group: AVgroup
7 user::rwx
8 user:yangmi:r-x
9 group::rwx
10 mask::rwx
11 other::---
12
13 [root@yinzhengjie ~]#
14 [root@yinzhengjie ~]# setfacl -b /yinzhengjie/
15 [root@yinzhengjie ~]# getfacl /yinzhengjie/
16 getfacl: Removing leading ‘/‘ from absolute path names
17 # file: yinzhengjie/
18 # owner: root
19 # group: AVgroup
20 user::rwx
21 group::rwx
22 other::---
23
24 [root@yinzhengjie ~]# ll -d /yinzhengjie/
25 drwxrwx---. 4 root AVgroup 4096 9月 28 12:56 /yinzhengjie/
26 [root@yinzhengjie ~]#
1 [root@yinzhengjie ~]# mkdir /yinzhengjie
2 [root@yinzhengjie ~]# touch /yinzhengjie/{1..5}.txt
3 [root@yinzhengjie ~]# ll /yinzhengjie/
4 总用量 0
5 -rw-r--r--. 1 root root 0 9月 28 23:29 1.txt
6 -rw-r--r--. 1 root root 0 9月 28 23:29 2.txt
7 -rw-r--r--. 1 root root 0 9月 28 23:29 3.txt
8 -rw-r--r--. 1 root root 0 9月 28 23:29 4.txt
9 -rw-r--r--. 1 root root 0 9月 28 23:29 5.txt
10 [root@yinzhengjie ~]#
11 [root@yinzhengjie ~]# setfacl -m u:yangmi:rx -R /yinzhengjie/
12 [root@yinzhengjie ~]#
13 [root@yinzhengjie ~]# ll /yinzhengjie/
14 总用量 20
15 -rw-r-xr--+ 1 root root 0 9月 28 23:29 1.txt
16 -rw-r-xr--+ 1 root root 0 9月 28 23:29 2.txt
17 -rw-r-xr--+ 1 root root 0 9月 28 23:29 3.txt
18 -rw-r-xr--+ 1 root root 0 9月 28 23:29 4.txt
19 -rw-r-xr--+ 1 root root 0 9月 28 23:29 5.txt
20 [root@yinzhengjie ~]#
21 [root@yinzhengjie ~]# getfacl /yinzhengjie/1.txt
22 getfacl: Removing leading ‘/‘ from absolute path names
23 # file: yinzhengjie/1.txt
24 # owner: root
25 # group: root
26 user::rw-
27 user:yangmi:r-x
28 group::r--
29 mask::r-x
30 other::r--
31
32 [root@yinzhengjie ~]#
原文:http://www.cnblogs.com/yinzhengjie/p/7609177.html