3. Re: t bit of chmod
From: Christopher Hicks <email@example.com>
On Fri, 4 Jul 1997, Meino Christian Cramer wrote:
> I've been struggled over the "t" and "T" bit of the chmod-command.
> The man-pages said for the t-bit "save program text on swap device (t)"
> (and what's about directories???)
> If I do a chmod 7552 I will get a "T" instead of "t" -- also no answer
> from the man-pages.
The t flag (a.k.a. the sticky bit) has an ancient purpose when applied to
files which is mainly of historical amusement on modern machines. It also
has a quite practical purpose when applied to directories.
First, the amusement. Back in the days when UNIX ran on machines with 16k
or less of RAM (!), it was a significant performance improvement to be
able to keep some programs accessible more quickly. Widely used programs
(such as vi) had their sticky bit set, so they'd 'stick' around. This
meant that even if noone was using vi at the moment, it would at least
stay in swap since swap was often a faster device and there's less
computation to swap something in than to start it up from scratch. With
modern OS's such as linux which dynamically allocate disk cache on
machines with up to a gigabyte of RAM, there is little value to the
sticky bit. For FILES, that is.
But the sticky bit is not just an anachronism. When applied to
directories it causes a quite valuable behaviour. It prevents people from
deleting or moving files they don't own. You might think "but UNIX
handles that anyway". Well, sort of. Deleting and renaming are dependant
on the permissions of the DIRECTORY. Since everyone has their own home
directory and has their own files in it, why would anyone care? Because
of tmp directories. Tmp directories are world writable. This would
normally allow anyone to delete or rename files in them -- whether they
owned the file or not. But that would make temporary directories
significantly less useful. So it was decided that the sticky bit would be
'overloaded' with a special behaviour when it was set on directories.
If you're interested in seeing all the sticky files and directories on
your system, try
find / -perm -1000 -ls
(This may not work on some commercial systems that use non-gnu versions
Free software isn't free, but expensive software is expensive
"Unix is hacker crack." -- Unix-Haters Handbook