Sticky bit definition
Sticky bit refers to a permission bit that can be set on a file or directory in a Unix-based operating system, such as Linux or macOS. Sticky bit prevents anyone without the permission to delete or rename a file or directory, even if other users have write permission to the directory.
See also: unauthorized access
Where is sticky bit used:
- TMP directory. Sticky bit helps prevent accidental file deletion by users who have write permissions to a directory. For example, as TMP is a directory allowing all users to create and modify files, setting the sticky bit ensures that users can only delete files they own.
- Shared directories. In directories shared among multiple users working on the same files, sticky bit can facilitate collaboration as it ensures other people’s files cannot be renamed or deleted. For example, by setting the sticky bit on a directory, users can create and modify files, but can only delete the files that they own. This can encourage users to work together on projects without the risk of one user accidentally deleting another user’s work.
- Executables. The sticky bit can also improve system performance because setting it on executable files in the Unix-based systems can speed up the execution of the programs you frequently use. This is because the file is kept in the system’s buffer cache after it has been executed.