Special Permissions Set_gid
Set_gid special permissions, which are functions in the user group permission bit, are also represented by an S.
In addition, Set_gid special permissions can also function in the directory. The function is that regardless of which user is currently logged on, as long as the directory is set to Set_gid permissions, then the new subdirectory and sub-files in this directory belong to the group consistent with the directory. PS: In a Linux system, by default, the user is logged in, the newly created files and directories (sub-files, subdirectories) belong to the user group where the user is located.
1. Action on the document
[[email protected] ~]# ls -l /usr/bin/ls-rwsr-xr-x. 1 root root 117656 11 Month 6 2016 /usr/bin/ls[[email protected] ~]# chmod u-s /usr/bin/ls[[email protected] ~]# !lsls -l /usr/bin/ls-rwxr-xr-x. 1 Root root 117656 11 Month 6 2016 /usr/bin/ls[[email protected] ~]# chmod g+s /usr/bin/ls[[email protected] ~]# !lsls -l /usr/bin/ Ls-rwxr-sr-x. 1 root root 117656 11 Month 6 2016 /usr/bin/ls[[email protected] ~]#
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706091044_834.png "style=" border-style:none; "/>
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706091045_210.png "style=" border-style:none; "/>
2. Role in the directory
1. directory does not set Set_gid permissions > which user login , new File/directory (sub-file/subdirectory) belongs to the user's group > chestnuts 1: Login to normal user Allin
[[email protected] tmp]$ mkdir 234/[[email protected] tmp]$ ls -ld 234/drwxrwxr-x. 2 allin1 allin1 6 6 Month 9 10:52 234/[[ Email protected] tmp]$ mkdir 234/123/[[email protected] tmp]$ ls -ld 234/123/drwxrwxr-x. 2 allin1 allin1 6 6 Month 9 10:53 234 /123/[[email protected] tmp]$ touch 234/1[[email protected] tmp]$ ls - L 234/1-rw-rw-r--. 1 allin1 allin1 0 6 Month    9 10:53 234/1 [[email protected] tmp]$
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706091053_747.png "style=" border-style:none; "/>
> Chestnut 2: Login to root user
[[Email protected] ~]# cd /tmp/[[email protected] tmp]# ls111 1. txt 222 234 allin2 allinlinux Systemd-private-0f4b60569c224727b1ec0153a8598630-vmtoolsd.service-qcx2tt tmp[[email protected] tmp]# mkdir 345/[[email protected] tmp]# ls -ld 345/drwxr-xr-x. 2 root root 6 6 Month 9 10:56 345/[[email protected] tmp]# mkdir 345/123/[[email protected] tmp]# ls -ld 345/123/drwxr-xr-x. 2 root root 6 6 Month 9 10:56 345/123/[[email protected] Tmp]# touch 345/1[[email protected] tmp]# ls -l 345/1-rw-r--r--. 1 root root 0 6 Month 9 10:56 345/1[[email protected] tmp]#
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706091056_913.png "style=" border-style:none; "/>
2. Directory settings Set_gid permissions > Regardless of which user is logged in, in the directory where the Set_gid permissions are set, the new sub-file/subdirectory is in the same group as the directory and is not affected by the login user. > Preset scenario: In the/tmp/directory, create a new directory/666/, change its owning group to User1, then set Set_uidquanxian for the directory, and finally use the root user. Observation results:
[[email protected] tmp]# ls -l Total dosage 4drwxrwxr--. 4 root root 45 6 month 8 21:20 111-rw-rw-r--. 1 root root 65 6 Month 8 21:16 1.txtdrwxr-xr-x. 2 root root 6 6 Month 8 20:11 222drwxrwxr-x. 3 allin1 allin1 26 6 Month 9 10:53 234drwxr-xr-x . 3 root root 26 6 Month 9 10:56 345drwxr-xr-x. 4 root root 40 6 Month 6 21:32 allin2drwxrwxrwx. 2 allin1 user1 19 6 Month 8 14:58 allinlinuxdrwx------. 3 root root 17 6 Month 8 14:15 systemd-private-0f4b60569c224727b1ec0153a8598630-vmtoolsd.service-qcx2ttdrwxr-xr-x. 4 root root 28 6 Month 6 17:16 tmp[[email protected] tmp]# mkdir 666/[[email protected] tmp]# ls -ld 666/drwxr-xr-x. 2 root root 6 6 month 9 11:01 666/[[email protected] tmp]# chown : user1 666/[[email protected] tmp]# ls -ld 666/drwxr-xr-x. 2 root User1 6 6 Month 9 11:01 666/[[email protected] tmp]# chmod g+s 666/[[email protected] tmp]# ls -ld 666/drwxr-sr-x. 2 root user1 6 6 Month 9 11:08 666/[[email protected] tmp]#
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706091103_897.png "style=" border-style:none; "/>
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706091110_280.png "style=" border-style:none; "/>
> Chestnut 1: Login Superuser root
[Email protected] tmp]# mkdir 666/111/[[email protected] tmp]# ls-ld 666/111/drwxr-sr-x. 2 Root user1 6 June 9 11:10 666/111/[[email protected] tmp]# touch 666/1[[email protected] tmp]# ls-l 666/1-rw-r--r--. 1 root user1 0 June 9 11:10 666/1[[email protected] tmp]#
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706091111_843.png "style=" border-style:none; "/>
This article is from the "Linux Road" blog, make sure to keep this source http://allin28.blog.51cto.com/12931477/1933859
Linux Special Permissions Set_gid