Re: the `t' bit

Shawn Bayern (shawn.bayern@yale.edu)
Thu, 25 Feb 1999 20:25:59 -0500 (EST)

On Thu, 25 Feb 1999, Ken Lai wrote:

> That's one sticky bit I don't understand yet. Would anyone like to
> enlighten me?

You just want a run-down of the sticky bit on Unix? First, the key thing
to realize is that its behavior is dependent on the system you're using
(the OS and the filesystem). In the most general sense, the sticky bit is
just an extra bit that can be used for implementation-defined stuff. As
the man page for chmod(2) on Linux describes, it's not documented by POSIX
or the XPG; there's no standard.

The most common use for the sticky bit is on directories; this use, at
least, is pretty standard. I described its effect in a post to this list
a while ago:

1000 represents the "sticky bit," which (on directories) means that
users can't delete files they don't own. By default, if a directory's
permissions give people "write" access, it means they can add and
delete files (and do the latter regardless of whether or not they own
the files).

The sticky bit, in contrast, sets things so that ordinary users can
delete only the files that they, in particular, own. Therefore, it's
useful for directories (like /tmp, /scratch, and /var/mail) that store
files owned by many users. In the "mail" directory, it's useful because
mail programs often want to create lockfiles there. Mode 1777 (as you
point out, all rwx plus "sticky") is typical for things like /tmp -- it
means "let any user add new files, but make sure they can only delete
files they own."

Whether or not normal users (as opposed to root) can set the sticky bit
depends on the filesystem.

> Btw, the Eric Raymond talk today was great! One suggestion for
> improvement is that perhaps if we get another speaker, we can arrange
> for some sort of dinner reception after the talk, then the speaker and
> interested people could have further discussion.

You should have come to the Doodle with us! Granted, Eric Raymond wasn't
here, but the burgers were good... :)

Shawn