Special Permissions Set_uid
By default, under a newly installed Linux system, only one command has SET_UID special permissions.
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706090852_784.png "style=" border-style:none; "/>
Command with s permission (file): In order to ensure that the non-owner user, in the use of the command, the temporary owner of the identity; Set SET_UID special permissions on a file, provided that the file is an executable binary (usually given a command with such special permissions), otherwise there is no meaning, such as to a folder to set a Set_uid permission, no practical significance.
1. Add set_uid Special permissions to the command
Format chmod u+s command file path chmod u+s/usr/bin/ls chmod u-s/usr/bin/ls
The permissions of the/root/directory are accessible only to the root user and the user under the root group, and no other user has any permissions.
[Email protected] ~]# ls-ld/root/dr-xr-x---. 3 root root 178 June 8 14:16/root/
Then if you use a normal user to view the contents of the/root/directory, you will certainly report insufficient permissions error.
[[email protected] ~]$ ls-l/root/ls: Unable to open Directory/root/: Insufficient permissions
After adding the Set_uid special command to the LS command, verify that you can temporarily add permissions to view the/root/directory with only the root user
[[email protected] ~]# which lsalias ls= ' Ls --color=auto '/usr/bin/ls[[email protected] ~]# ls -l /usr/bin/ls-rwxr-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-rwsr-xr-x. 1 root root 117656 11 month 6 2016 /usr/bin/ls[[email protected] ~]#
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706090922_764.png "style=" border-style:none; "/>
Switch to the normal user of allin1, use the LS command again to see if the normal user has the root user permission, can view the/root/directory
[[email protected] ~]# ssh -p 22 [email protected] login: fri jun 9 08:54:21 2017 from 192.168.245.132[[email protected] ~]# whoamiroot[[email protected] ~]# su - allin1 Last Login: five 6 month 9 08:54:30 cst 2017pts/3 on [[email protected] ~]$ whoamiallin1[[email Total dosage of protected] ~]$ ls -l /root/ 8-rwx--x--x. 1 root root 0 6 month    8 14:16 2.TXT-RW-------. 1 root root 7728 6 month 6 22:11 anaconda-ks.cfg.1[[email protected] ~]$
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706090927_73.png "style=" border-style:none; "/>
2. Second way to add Set_uid special permissions to a command
Format: chmod u=rws command file path chmod u=rws/usr/bin/ls
So the permissions of the modified LS command are different from the first way modified by the LS command, but the effect is the same
[[email protected] ~]# chmod u-s /usr/bin/ls[[email protected] ~]# ls -l /usr/bin/ls-rwxr-xr-x. 1 root root 117656 11 Month 6 2016 /usr/bin/ls[[email protected] ~]# chmod u=rws /usr/bin/ls[[email protected ] ~]# ls -l /usr/bin/ls-rwsr-xr-x. 1 root root 117656 11 month 6 2016 /usr/bin/ls[[email protected] ~]#
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706090933_155.png "style=" border-style:none; "/
[[email protected] ~]$ ls -l /usr/bin/ls-rwsr-xr-x. 1 root root 117656 11 Month 6 2016 /usr/bin/ls[[email protected] ~]$ ls -l / Bin/ls-rwsr-xr-x. 1 root root 117656 11 Month 6 2016 /bin/ls[[email Total dosage of protected] ~]$ ls -l /root/ 8-rwx--x--x. 1 root root 0 6 month    8 14:16 2.TXT-RW-------. 1 root root 7728 6 month 6 22:11 anaconda-ks.cfg.1[[email protected] ~]$
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706090937_414.png "style=" border-style:none; "/>
Plus x permissions
[Email protected] ~]# chmod u+x/usr/bin/ls[[email protected] ~]# ls-l/usr/bin/ls-rwsr-xr-x. 1 root root 117656 November 6 2016/usr/bin/ls
650) this.width=650; "src=" Http://oqjg6c4c1.bkt.clouddn.com/201706090938_443.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/1933858
Linux Special Permissions Set_uid