Sunday, June 12, 2011

File Permission Linux

xxxxxxxxxxxxxxxxxxxxxx File Permission xxxxxxxxxxxxxxxxxx

Set user ID, set group ID, sticky bit

- SUID or setuid: Change user ID on execution. If setuid bit is set, when the file will be executed by a user,   the process will have the same rights as the owner of the file being executed.
- SGID or setgid: Change group ID on execution. Same as above, but inherits rights of the group of the owner of the file on execution. For directories it also may mean that when a new file is created in the directory it will inherit the group of the directory (and not of the user who created the file).
- Sticky bit:  It was used to trigger process to "stick" in memory after it is finished, now this usage is obsolete. Currently its use is system dependant and it is mostly used to suppress deletion of the files that belong to other users in the folder where you have "write" access to.
               -->> If the sticky bit is set for a directory, only the owner of that directory or the owner of a file can delete or rename a file within that directory.

SUID bit is set for files ( mainly for scripts ). 
The SUID permission makes a script to run as the user who is the owner of the script, rather than the user who started it.

SGID, it will run with the privileges of the files group owner, instead of the privileges of the person running the program.

0755 -> setuid, setgid, sticky bits are cleared        000
1755 -> sticky bit is set                                              001
2755 -> setgid bit is set                                             010
3755 -> setgid and sticky bits are set                      011
4755 -> setuid bit is set                                             100
5755 -> setuid and sticky bits are set                      101    
6755 -> setuid and setgid bits are set                     110
7755 -> setuid, setgid, sticky bits are set                111