Linux exercise 13 default permissions and special permissions examples
Project 1. Default permissions
1. View the umask values of common users user1 and root users respectively
[root@localhost aoian] # umask
0022
[root@localhost aoian] # useradd user1
root@localhost aoianj # su user1
user1 @localhost aoian] $ umask
0002
2. Use user1 to create a folder dir and file file, and view their attributes
$ mkdir dir
$ touch file
$ ll
drwxrwxr- x.2 user1 userl 6 11月 13 18: 58 dir
-rW-rW-r-- .1 userl userl 0 11月 13 18: 59 file
3. Summarize how the default permissions of new files and folders for ordinary users and root users are determined
The maximum file permission is 666
The maximum permission of the directory is 777
Ordinary user umask-0002
666-002 is 664
777-002 is 775
Calculated that the default permissions of ordinary user files are 664
The default permission of the folder is 775
The same
Root user umask-0022
Calculated that the default file permissions are 644
The default permission of the directory is 755
Item 2. Examples of special permissions
Suppose there are two accounts in the system, user1 and user2. In addition to their own group, these two people also belong to a group named project. Assume that these two users need to jointly own the development rights of the /home/net/ directory, and that the directory does not allow other people to access it. How should the permissions of this directory be set?
[root@localhost aoian]# groupadd project
[root@localhost aoian]# useradd -G project user1
[root@localhost aoian]# useradd -G project user2
[root@localhost aoian]# mkdir /home/net
[root@localhost aoian]# chgrp project /home/net
[root@localhost aoian]# cd /home
[root@localhost home]# ll
总用量 4
drwx------. 16 aoian aoian 4096 10月 16 09:50 aoian
drwxr-xr-x. 2 root project 6 11月 13 20:44 net
drwx------. 3 user1 user1 78 11月 13 20:43 user1
drwx------. 3 user2 user2 78 11月 13 20:43 user2
[root@localhost home]# chmod 2770 net
[root@localhost home]# ll
总用量 4
drwx------. 16 aoian aoian 4096 10月 16 09:50 aoian
drwxrws---. 2 root project 6 11月 13 20:44 net
drwx------. 3 user1 user1 78 11月 13 20:43 user1
drwx------. 3 user2 user2 78 11月 13 20:43 user2
chomd 2770 net ------------>>SGID: 2 modify special permissions
If chomd 770 net, user2 has insufficient permissions
Switch user test
[root@localhost home]# su user1
[user1@localhost home]$ cd net
[user1@localhost net]$ touch user01
[user1@localhost net]$ ll
总用量 0
-rw-rw-r--. 1 user1 project 0 11月 13 20:50 user01
[user1@localhost net]$ exit
exit
[root@localhost home]# ll
总用量 4
drwx------. 16 aoian aoian 4096 10月 16 09:50 aoian
drwxrws---. 2 root project 20 11月 13 20:50 net
drwx------. 5 user1 user1 128 11月 13 20:55 user1
drwx------. 3 user2 user2 78 11月 13 20:43 user2
[root@localhost home]# su user2
[user2@localhost home]$ cd net
[user2@localhost net]$ ls
user01
[user2@localhost net]$ exit
exit
New user3 test
[root@localhost home]# useradd user03
[root@localhost home]# su user03
[user03@localhost home]$ ls
aoian net user03 user1 user2
[user03@localhost home]$ cd net
bash: cd: net: 权限不够