SUID, SGID, and Sticky attributes of the file
SUID attributes
The SUID attribute is generally used on an executable file. When a user executes the file, the user temporarily has the permission of the owner of the executable file. When you use the "ls-l" or "ll" command to browse a file, if the third digit of the executable file owner permission is a lowercase "s ", it indicates that the execution file has the SUID attribute. For example, the/usr/bin/passwd file.
$ Ll/usr/bin/passwd-rwsr-xr-x 1 root 41284 April 9 2012/usr/bin/passwd
SGID attributes
When the SGID attribute is applied to a directory, the owner Group of the files or subdirectories created in the directory will be the owner Group of the directory. When the SGID attribute is applied to an executable file, other users temporarily have group permissions for the executable file when using the file. When you use the "ls-l" or "ll" command to browse a directory, if the third digit with group permissions is a lowercase "s ", it indicates that the execution file or directory has the SGID attribute.
Sticky Bit attribute
The Sticky attribute can only be applied to the directory. When the directory has the Sticky attribute, only the owner of the file or sub-directory and the root user can delete all files or sub-directories in the directory regardless of the permission. When you use the "ls-l" or "ll" command to browse the directory, if the third digit of other user permissions is a lowercase "t ", it indicates that the execution file or directory has the Sticky attribute.
Note: The linux system requires that, if there is x on this digit, these attributes are displayed with lowercase letters (valid); otherwise, uppercase letters (invalid) are displayed)
Configure the SUID, SGID, and Sticky attributes
Character configuration can be used (s represents SUID and SGID, t represents Sticky)
For example:
Chmod u + s test_file # Add the SUID attribute chmod g + s test_dir to the file # Add the SGID attribute chmod o + t test_dir # Add the Sticky attribute to the directory
You can also configure it using numbers (4 indicates SUID, 2 indicates SGID, and 1 indicates Sticky)
For example:
Chmod 4555 test_file # Add the SUID attribute chmod 2555 test_file # Add the SGID attribute chmod 1555 test_dir # Add the Sticky attribute to the file