sticky bit on files and directories

I’ve always heard that sticky bit should be only used with directories, and I understand that, but what is the meaning if it is applied to a file. If I set the sticky bit to a file and do an ls -la I see a capital T, but I don’t know if this influences the behaviour of the file.

Asked By: std124_lf

||

For executable files, this is the resident bit. It can be set by the administrator to tell the OS to keep the program code in swap space even if it is not running at the moment.

Modern Operating Systems have sophisticated memory management algorithms that generally do a much better job at managing memory than humans could, so this bit is ignored and has been for decades. It is obsolete and essentially meaningless in any OS that can even remotely be called modern.

Unless you are into retro-computing, you will never encounter an OS that interprets it. Linux, for example, has never implemented it. Solaris removed it in 2005.

For non-executable files, the sticky bit is used on Solaris to tell the OS that this file should not be cached. It is generally set on swap files.

Answered By: Jörg W Mittag

This is a case of RTFM

From man 1 chmod:

Restricted Deletion Flag or Sticky Bit 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 renaming 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 directories 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.

Answered By: waltinator
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.