[sf-lug] What is the sticky bit?

Grant Bowman grantbow at gmail.com
Fri Apr 2 04:11:25 PDT 2010

What is the sticky bit?  This question came up and started an
interesting discussion, prompting me to take a closer look at exactly
how ext2 does it's work.  A sticky bit is well described in a
paragraph of the chmod man page. [1]

Jim, thanks for the fascinating discussion Wednesday at the
Noisebridge Linux Discussion group. [2]  I was amazed at how much of
what I thought I knew pretty well and have anecdotally learned over
the years I actually don't comprehend it enough to fully describe it
to other people.  I found this document very useful in learning some
of the details of what we discussed.


So what is a directory?  It is a special type of inode.  Each block
group has it's own inode table that contains not only the file name
and inode reference but in later ext2 "revisions" also contains a copy
of the file type of the referenced inode.  I hope others on the list
will find some of this useful.



       The  restricted  deletion flag or sticky bit is a single bit,
whose interpretation depends
       on the file type.  For directories, it prevents unprivileged
users from removing or renam‐
       ing  a file in the directory unless they own the file or the
directory; this is called the
       restricted deletion flag for the directory, and is commonly
found on world-writable direc‐
       tories  like  /tmp.   For regular files on some older systems,
the bit saves the program's
       text image on the swap device so it will load more quickly when
run; this  is  called  the
       sticky bit.

[2] https://www.noisebridge.net/wiki/LinuxDiscussion

More information about the sf-lug mailing list