Sticky bit

from Wikipedia, the free encyclopedia

The sticky bit (also t-bit or save text bit ) is an extended file right , ie a file attribute under Unix . It affects directories and files differently.

notation

In symbolic notation , the sticky bit is noted on the last of the nine characters. That xwill be replaced by t. If the execute right is not set for the other user class , which means that the ninth character -is a, then it is replaced by a capitalized one Tat this point. This rwxrwxrwxis how it is rwxrwxrwt, rwxr--r--but it is rwxr--r-T.

In octal notation , the sticky bit, like all three extended file rights, is noted in an octal digit before the three file right octal digits. The 0value is 1added to the number there (which is not set if the extended file rights are set) if the sticky bit is set. From 0755becomes so 1755, from 4744becomes 5744.

effect

For executable files

In its original meaning, the sticky bit was used for executable files, i.e. programs with execute file rights. The effect was that the program was not removed from the main memory after the associated process had ended and therefore did not have to be reloaded from secondary memory (e.g. hard disk ) to primary memory (main memory) and relocated again when the program was called up again. This led to speed advantages in large programs that are used frequently, for example editors.

This function is to be regarded as historical; it is no longer implemented in the historical form on modern Unix derivatives. So was z. For example, with the introduction of SunOS 4.0 in 1988, the sticky bit was used to prevent written file contents from being cached on an NFS server . This fixed a performance problem when using NFS-based swap files.

With directories

The sticky bit enables the creation of shared directories.

For example, if a directory has set ( or ) all file rights for all users , then every user can create files (and subdirectories) in this directory, but also delete every file in it. Setting the sticky bit restricts access to the files in this directory, so that only the owner of a file (or the owner of the directory) can delete or rename this file. The rights to read and write the files remain unaffected. The sticky bit is used, for example, for . 777rwxrwxrwx/tmp

See also