- What is the “sticky bit”? (t and T)
The sticky bit is primarily used on shared directories. It is useful for shared directories such as /var/tmp and /tmp/ because users CAN CREATE files, READ and EXECUTE files owned by other users, but ARE NOT ALLOWED to REMOVE files owned by other users. Of course, users CAN REMOVE their own files.
The sticky bit (file mode bit 01000) is used to indicate special treatment of certain files and directories. A directory for which the sticky bit is set restricts deletion of files it contains. A file in a sticky directory may only be removed or renamed by a user who has write permission on the directory, and either owns the file, owns the directory, or is the super-user. This is useful for directories such as /tmp, which must be publicly writable, but should deny users permission to arbitrarily delete or rename the files of others.
drwxrwxrwt 2 sys sys 512 Jun 20 11:02 /var/tmp
See the “t”? That tells us that the sticky bit is set.
A “T” refers to when the execute permissions are OFF.
A “t” refers to when the execute permissions are ON.
# chmod 1771 <path_to_directory> (permissions for “other” have execute bit ON)
# chmod 1770 <path_to_directory> (permissions for “other” have execute bit OFF)