File Special permissions set Uid,setgid,setbit
1.Set UID: When the S flag appears on the owner's X-permission, this is called the Set UID, which is referred to as the special permission of SUID. Basically suid have such limitations and functions
1) suid permissions are valid only for binary programs
2) Performer must have X executable permission for the program
3) This permission is valid only in the course of executing the program
4) The performer will have the rights of the owner of the program
Eg: in the Linux system, all account passwords are recorded in the/etc/shadow file, the file permissions are:-R--------1 root root, that is, only the root readable, can be forced to write. Although the file can be changed only by root, users can use their own account to change the password by typing passwd.
The reason is: ordinary users of/USR/BIN/PASSWD this program is the x permission, passwd owner is root, the ordinary user in the process of executing passwd will temporarily get root permissions, so ordinary users can modify their own password.
2.Set GID: When the S flag appears in the group's X-permission position, called set GID, referred to as sgid, unlike Suid, Sgid can be set for files and directories, which function on the file:
1) sgid useful for binary programs
2) Program performer has x permission for the program
3) The performer will receive support from the group during the execution
function on the file, its functions are:
1) If the user has R and X permissions for this directory, the user can enter this directory
2) A valid group of users in this directory will become a group of that directory
3) Use: If the user has W permission in this directory, then the new file created by the users, the group of the file is the same as the group of this directory
3.Sticky Bit: Only valid for directory, generally for other people's X permission location, its function is:
1) When the user has w,x permissions on this directory, that is, permission to write
2) When the user creates a file or directory under this directory, only himself and Root have the right to delete the file
Eg: When a user has a group or other person's identity for the A directory, and owns the directory W permission, this means that a user can "delete/rename/move" The directory or file created by any person in the directory. However, when a directory is added to the Sbit permission item, a can only be deleted/renamed/moved for the file or directory you have created, and cannot delete the files of others.
4. The above special permission settings: It is well known that with three numbers can set the permissions of the file, then if you add a number before the three numbers, the first number represents these permissions.
1) 4 for SUID
2) 2 for Sgid
3) 1 for Sbit
Eg: Join to change the permissions of a file to:-rwsr-xr-x, because s in the user's permissions, so is suid, therefore, before the original 755 plus 4, that is, chmod 4755 filename to set.
In addition, ST corresponds to the null permission, because the ST permission is based on the executable, once the file does not have the enforceable permission, then the file will produce the empty St permission, namely St.
Alternatively, you can use the + 、-、 = To set permissions (including special permissions) for the file.
This article is from "Tiger Brother's Blog" blog, please be sure to keep this source http://7613577.blog.51cto.com/7603577/1590312
Linux File Special Permissions Suid,sgid,sbit