useradd four
useradd tea1
useradd tea2
useradd tea3
useradd stu1
useradd stu2
useradd stu3
[zhuofai@localhost ~]$ su four
密码:
[zhuofai@localhost ~]$ su
密码:
[root@localhost zhuofai]# su four
[four@localhost zhuofai]$ cd /home/four
[four@localhost ~]$ ls
[four@localhost ~]$ ll
总用量 0
[four@localhost ~]$ cd …
[four@localhost home]$ chmod 770 four
[four@localhost home]$ ll
总用量 4
drwxrwx—. 5 four four 107 3月 16 17:07 four
drwx------. 5 sb sb 144 3月 16 17:01 sb
drwx------. 3 stu1 stu1 78 3月 16 17:01 stu1
drwx------. 3 stu2 stu2 78 3月 16 17:01 stu2
drwx------. 3 stu3 stu3 78 3月 16 17:01 stu3
drwx------. 3 tea1 tea1 78 3月 16 17:00 tea1
drwx------. 3 tea2 tea2 78 3月 16 17:00 tea2
drwx------. 3 tea3 tea3 78 3月 16 17:00 tea3
drwx—r-x. 2 root root 21 3月 16 14:52 three
drwx------. 15 zhuofai zhuofai 4096 3月 16 16:33 zhuofai
[four@localhost home]$ su
密码:
[root@localhost home]# usermod tea1 -aG four
[root@localhost home]# id tea1
uid=1004(tea1) gid=1005(tea1) 组=1005(tea1),1004(four)
[root@localhost home]# usermod tea2 -aG four
[root@localhost home]# usermod tea3 -aG four
[root@localhost home]# usermod stu1 -aG four
[root@localhost home]# usermod stu2 -aG four
[root@localhost home]# usermod stu3 -aG four
[root@localhost home]# useradd teacherG
[root@localhost home]# usermod teacherG -aG four
[root@localhost home]# su teacherG
[teacherG@localhost home]$ ll
总用量 4
drwxrwx—. 5 four four 107 3月 16 17:08 four
drwx------. 5 sb sb 144 3月 16 17:01 sb
drwx------. 3 stu1 stu1 78 3月 16 17:01 stu1
drwx------. 3 stu2 stu2 78 3月 16 17:01 stu2
drwx------. 3 stu3 stu3 78 3月 16 17:01 stu3
drwx------. 3 tea1 tea1 78 3月 16 17:00 tea1
drwx------. 3 tea2 tea2 78 3月 16 17:00 tea2
drwx------. 3 tea3 tea3 78 3月 16 17:00 tea3
drwx------. 5 teacherG teacherG 107 3月 16 17:10 teacherG
drwx—r-x. 2 root root 21 3月 16 14:52 three
drwx------. 15 zhuofai zhuofai 4096 3月 16 16:33 zhuofai
[teacherG@localhost home]$ cd four
[teacherG@localhost four]$ mkdir teacher
[teacherG@localhost four]$ ll
总用量 0
drwxrwxr-x. 2 teacherG teacherG 6 3月 16 17:10 teacher
[teacherG@localhost four]$ chmod 770 teacher/
[teacherG@localhost four]$ ll
总用量 0
drwxrwx—. 2 teacherG teacherG 6 3月 16 17:10 teacher
[teacherG@localhost four]$ useradd studentG
useradd: Permission denied.
useradd:无法锁定 /etc/passwd,请稍后再试。
[teacherG@localhost four]$ su
密码:
[root@localhost four]# useradd studentG
[root@localhost four]# usermod studentG -aG four
[root@localhost four]# su studentG
[studentG@localhost four]$ mkdir student
[studentG@localhost four]$ ll
总用量 0
drwxrwxr-x. 2 studentG studentG 6 3月 16 17:12 student
drwxrwx—. 2 teacherG teacherG 6 3月 16 17:10 teacher
[studentG@localhost four]$ su
密码:
[root@localhost four]# usermod tea1 -aG teacherG
[root@localhost four]# usermod tea2 -aG teacherG
[root@localhost four]# usermod tea3 -aG teacherG
[root@localhost four]# id tea1
uid=1004(tea1) gid=1005(tea1) 组=1005(tea1),1004(four),1011(teacherG)
[root@localhost four]# usermod stu1 -aG studentG
[root@localhost four]# usermod stu2 -aG studentG
[root@localhost four]# usermod stu3 -aG studentG
[root@localhost four]# id stu1
uid=1007(stu1) gid=1008(stu1) 组=1008(stu1),1004(four),1012(studentG)
[root@localhost four]# cd …
[root@localhost home]# chmod 750 four
[root@localhost home]# ll
总用量 4
drwxr-x—. 7 four four 137 3月 16 17:12 four
drwx------. 5 sb sb 144 3月 16 17:01 sb
drwx------. 3 stu1 stu1 78 3月 16 17:01 stu1
drwx------. 3 stu2 stu2 78 3月 16 17:01 stu2
drwx------. 3 stu3 stu3 78 3月 16 17:01 stu3
drwx------. 5 studentG studentG 107 3月 16 17:12 studentG
drwx------. 3 tea1 tea1 78 3月 16 17:00 tea1
drwx------. 3 tea2 tea2 78 3月 16 17:00 tea2
drwx------. 3 tea3 tea3 78 3月 16 17:00 tea3
drwx------. 5 teacherG teacherG 107 3月 16 17:11 teacherG
drwx—r-x. 2 root root 21 3月 16 14:52 three
drwx------. 15 zhuofai zhuofai 4096 3月 16 16:33 zhuofai
[root@localhost home]# su stu1
[stu1@localhost home]$ cd four
[stu1@localhost four]$ ll
总用量 0
drwxrwxr-x. 2 studentG studentG 6 3月 16 17:12 student
drwxrwx—. 2 teacherG teacherG 6 3月 16 17:10 teacher
[stu1@localhost four]$ cd teacher/
bash: cd: teacher/: 权限不够
[stu1@localhost four]$ cd student/
[stu1@localhost student]$ touch one.xt
[stu1@localhost student]$ ll
总用量 0
-rw-rw-r–. 1 stu1 stu1 0 3月 16 17:14 one.xt
[stu1@localhost student]$ su
密码:
[root@localhost student]# su tea1
[tea1@localhost student]$ cd …
[tea1@localhost four]$ cd …
[tea1@localhost home]$ cd four
[tea1@localhost four]$ ll
总用量 0
drwxrwxr-x. 2 studentG studentG 20 3月 16 17:14 student
drwxrwx—. 2 teacherG teacherG 6 3月 16 17:10 teacher
[tea1@localhost four]$ touch 1.txt
touch: 无法创建"1.txt": 权限不够
[tea1@localhost four]$ cd teacher/
[tea1@localhost teacher]$ touch 1.txt
[tea1@localhost teacher]$ cd …
[tea1@localhost four]$ cd student/
[tea1@localhost student]$ ls
one.xt
[tea1@localhost student]$ ll
总用量 0
-rw-rw-r–. 1 stu1 stu1 0 3月 16 17:14 one.xt
[tea1@localhost student]$