Sticky Bit is used on folders in to avoid
deletion of its content by users who are in same group with the owner of the file.
Before understanding the sticky bit, I recommend reading SGID post which explains its disadvantage.
From SGID we understood that the user E1 can delete the file of E2 and vice versa.
So to avoid this, we use sticky bit.
Command
To set:
chmod o+t <dir>
To unset:
chmod o-t <dir>
eg:
# chmod o+t /project/
# ls -ld /project/
drwxrws--T. 2 root teamA 84 Aug 31 09:03 /project/
You will notice T in others permission.
Now the user E1 cannot delete file of E2 and E2 cannot delete of E1.
Below example shows E1 user trying to delete file of E2 but sticky bit didnt allow the file to get deleted.
$ rm e2_file.txt
rm: remove write-protected regular empty file ‘e2_file.txt’? y
rm: cannot remove ‘e2_file.txt’: Operation not permitted
Before understanding the sticky bit, I recommend reading SGID post which explains its disadvantage.
From SGID we understood that the user E1 can delete the file of E2 and vice versa.
So to avoid this, we use sticky bit.
Command
To set:
chmod o+t <dir>
To unset:
chmod o-t <dir>
eg:
# chmod o+t /project/
# ls -ld /project/
drwxrws--T. 2 root teamA 84 Aug 31 09:03 /project/
You will notice T in others permission.
Now the user E1 cannot delete file of E2 and E2 cannot delete of E1.
Below example shows E1 user trying to delete file of E2 but sticky bit didnt allow the file to get deleted.
$ rm e2_file.txt
rm: remove write-protected regular empty file ‘e2_file.txt’? y
rm: cannot remove ‘e2_file.txt’: Operation not permitted
Comments
Post a Comment