3

The way I understand the sticky bit on directories is that only the owner of a file within that directory can delete the file, instead of everybody with write permission.

I don't get, though, where that would be actually useful. If everybody can still edit my file, including just deleting all the contents, what scenario is there where the sticky bit actually helps?

I have read that it is used on /tmp, I don't get why that is either.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Tim
  • 33
  • 2

1 Answers1

4

In general, files are created with no write permission for anyone but the owner (with a umask of 022). Thus files created in a shared directory, such as /tmp, can’t be edited by other users.

Adding the sticky bit ensures that files can’t be deleted either (as you explained).

Nowadays it’s common to use private subdirectories of shared directories, for added privacy: that way, other users can’t see the file names you use.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164