LX0-103 · Question #155
The sticky bit is usually set on
The correct answer is B. /tmp. The sticky bit on a directory restricts file deletion so that only the file's owner can remove it, even if other users have write permission to that directory. /tmp is the canonical example because it is world-writable and shared by all users.
Question
The sticky bit is usually set on
Options
- A/var/log
- B/tmp
- C/home
- Dlog files
How the community answered
(34 responses)- A6% (2)
- B85% (29)
- C6% (2)
- D3% (1)
Why each option
The sticky bit on a directory restricts file deletion so that only the file's owner can remove it, even if other users have write permission to that directory. /tmp is the canonical example because it is world-writable and shared by all users.
/var/log is typically writable only by root or specific system accounts, so the sticky bit protection against arbitrary deletion is not needed or conventionally applied there.
The /tmp directory is world-writable (mode 1777), meaning every user can create files there, but without the sticky bit any user could delete anyone else's files. The sticky bit (the leading 1 in 1777) ensures that only the file owner, the directory owner, or root can remove a file, preventing one user from interfering with another's temporary data.
/home contains per-user home directories owned by individual users; since other users do not have write access to a user's home directory by default, the sticky bit is not required.
The sticky bit is a directory permission concept; applying it to individual log files has no practical effect in modern Linux kernels.
Concept tested: Sticky bit usage on shared writable directories
Source: https://man7.org/linux/man-pages/man1/chmod.1.html
Topics
Community Discussion
No community discussion yet for this question.