Chmod Sticky Bit Formula:
From: | To: |
The sticky bit is a permission bit that can be set on directories in Unix-like systems. When set on a directory, it restricts file deletion so that only the file owner, directory owner, or root can delete files within it.
The calculator uses the sticky bit formula:
Where:
Explanation: The sticky bit adds 1000 to the base permission mode in octal notation. This results in a 4-digit mode where the first digit represents special permissions.
Details: The sticky bit is commonly used on directories like /tmp to prevent users from deleting files owned by others, while still allowing them to create and modify their own files.
Tips: Enter the base 3-digit octal permission (e.g., 755, 644). The calculator will add the sticky bit (1000) and show the resulting 4-digit mode.
Q1: How do I set the sticky bit using chmod?
A: You can use either chmod +t directory
or chmod 1777 directory
(where 1777 is the sticky bit plus full permissions).
Q2: How can I tell if a directory has the sticky bit set?
A: Use ls -ld directory
and look for a 't' or 'T' in the execute bit of others permissions (e.g., drwxrwxrwt).
Q3: What's the difference between 't' and 'T' in ls output?
A: 't' means sticky bit is set and execute is set for others. 'T' means sticky bit is set but execute is not set for others.
Q4: Can I set sticky bit on files?
A: While technically possible, it has no effect on modern Unix systems. It's only meaningful for directories.
Q5: What are other special permission bits?
A: The setuid bit (4000) and setgid bit (2000) are other special permissions that can be combined with the sticky bit.