SUID ,SGID ,sticky bit

So what is the sticky bit?

A sticky bit is a permission bit that is set on a directory that allows only the owner of the file within that directory or the root user to delete or rename the file. No other user has the needed privileges to delete the file created by some other user.
This is a security measure to avoid deletion of critical folders and their content (sub-directories and files), though other users have full permissions.

Why does /tmp have the t sticky bit?

The /tmp directory can be used by different Linux users to create temporary files. Now, what if an user deletes/rename a file created by some other user in this directory?
Well, to avoid these kind of issues, the concept of sticky bit is used. So for that a 777 is given but preserving the sticky bit is not a bad idea.
A stickybit is a workaround method for shared directories not to be deleted accidentally. When a directory has a stickybit then only the owner or the root can delete it even that every user can take the full other permissions.
/tmp is the most shared directory between processes and users and for that it contains the stickybit to ensure that no user can delete the directory, even that the permission is 777 , and it must be so to give the ability to the users and processes to use the directory without conflict in permissions.

This usage of the sticky bit only applies to directories, not files.

sticky bit
$ chmod +t directory     or    $ chmod 1754 directory
$ chmod -t directory     or    $ chmod  754 directory
 
 
SGID 
chmod g+s reids.pl or chmod 2755 reids.pl 
$ chmod g-s reids.pl
$ chmod 755 reids.pl
 
SUID 
# chmod u+s /home/venu/reids.pl
To assign SUID in an absolute manner, simply prefix 4 to whatever
octal string you would otherwise use (like 4755 instead of 755) 

No comments:

Post a Comment