Restricted Deletion Flag

tux_compDid you ever encounter a situation where you need to share a directory which multiple users can access and create files in, but can’t delete each other’s files? Sounds familiar? We are talking of the Restricted Deletion Flag aka Sticky Bit.

The sticky bit is the perfect solution for the problem I introduced above, and the /tmp directory in the Linux based filesystems use this feature to store temporary files from multiple users where no user (other than root) can remove or rename the file belonging to another user. Note that we are discussing sticky set for a directory here.

You can verify that sticky (denoted by t) is set for /tmp in your Linux box:

$ sudo ls -l /
drwxrwxrwt 7 root root 280 Oct 3 18:33 tmp

Setting the sticky bit is similar to setting permissions:

$ chmod +t somedir
$ ls -l .
drwxrwxr-t 2 neo neo 4.0K Oct 3 19:08 somedir/

Leave a Reply

Your email address will not be published. Required fields are marked *