LX0-103 · Question #63
Which of the following commands set the sticky bit for the directory /tmp? (Choose TWO correct answers.)
The correct answer is B. chmod +t /tmp C. chmod 1775 /tmp. The sticky bit on a directory prevents users from deleting or renaming files they do not own, and it is set using either the symbolic '+t' flag or the octal prefix '1'.
Question
Which of the following commands set the sticky bit for the directory /tmp? (Choose TWO correct answers.)
Options
- Achmod +s /tmp
- Bchmod +t /tmp
- Cchmod 1775 /tmp
- Dchmod 4775 /tmp
- Echmod 2775 /tmp
How the community answered
(44 responses)- A2% (1)
- B91% (40)
- D5% (2)
- E2% (1)
Why each option
The sticky bit on a directory prevents users from deleting or renaming files they do not own, and it is set using either the symbolic '+t' flag or the octal prefix '1'.
chmod +s sets the setuid bit on files or the setgid bit on directories, not the sticky bit.
chmod +t /tmp uses symbolic mode to add the sticky bit (represented as 't' in ls output) to the directory, leaving other permission bits unchanged.
chmod 1775 /tmp uses octal notation where the leading '1' encodes the sticky bit, '7' grants rwx to owner, '7' to group, and '5' (rx) to others - a common real-world setting for /tmp.
chmod 4775 sets the setuid bit (leading octal digit 4), which causes executables to run as the file owner, not the sticky bit.
chmod 2775 sets the setgid bit (leading octal digit 2), which causes new files in the directory to inherit the group, not the sticky bit.
Concept tested: Setting the sticky bit on Linux directories
Source: https://man7.org/linux/man-pages/man1/chmod.1.html
Topics
Community Discussion
No community discussion yet for this question.