原文:http://www.techcuriosity.com/resources/linux/advanced_file_permissions_in_linux.php
Here we will discuss about the 3 special attributes other than the common read/write/execute.
Example:
drwxrwxrwt - Sticky Bits - chmod 1777
drwsrwxrwx - SUID set - chmod 4777
drwxrwsrwx - SGID set - chmod 2777
| |
Sticky bits are mainly set on directories. Example: Example: ls -al From the above example a1 is the owner of the test directory. |
| |
SUID bit is set for files ( mainly for scripts ). Example: Note: |
| |
If a file is SGID, it will run with the privileges of the files group owner, instead of the privileges of the person running the program. You can also set SGID for directories. Example: In the above example you can see that the owner of the file 1.txt is b2 and the group owner is a1. Now lets make this more intresting and complicated. Example: ls -al test From the above permission set you can understand that SGID and sticky bit is set for the folder "test". Example: So all the a1 user has access to all the files under the test directory. He can edit, rename or remove the file. If sticky bit was not set for the test directory, any user can delete any files from the test directory, since the test directory has 777 permissions. Example: |