1

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.

2 Answers 2

2

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.

2

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.