LFCS · Question #663
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. To set the sticky bit for a directory, you can use either the symbolic mode +t or the octal mode 1xxx where xxx represents the base permissions.
Question
Options
- Achmod +s /tmp
- Bchmod +t /tmp
- Cchmod 1775 /tmp
- Dchmod 4775 /tmp
- Echmod 2775 /tmp
How the community answered
(48 responses)- A2% (1)
- B90% (43)
- D2% (1)
- E6% (3)
Why each option
To set the sticky bit for a directory, you can use either the symbolic mode `+t` or the octal mode `1xxx` where `xxx` represents the base permissions.
The `chmod +s /tmp` command sets the SetUID or SetGID bit, not the sticky bit.
The `chmod +t /tmp` command uses symbolic mode to explicitly add the sticky bit to the `/tmp` directory, preventing non-owners from deleting or renaming files they don't own within it.
The `chmod 1775 /tmp` command uses octal mode, where the leading `1` sets the sticky bit, and `775` specifies read, write, and execute permissions for the owner and group, and read and execute for others.
The `chmod 4775 /tmp` command sets the SetUID bit, indicated by the leading `4`, not the sticky bit.
The `chmod 2775 /tmp` command sets the SetGID bit, indicated by the leading `2`, not the sticky bit.
Concept tested: Linux file permissions (sticky bit)
Source: https://linux.die.net/man/1/chmod
Topics
Community Discussion
No community discussion yet for this question.