LFCS · Question #869
Which of the following commands makes /bin/foo executable by everyone but writable only by its owner?
The correct answer is A. chmod u=rwx,go=rx /bin/foo. To make a file executable by everyone but writable only by its owner, chmod can be used with the symbolic mode u=rwx,go=rx.
Question
Options
- Achmod u=rwx,go=rx /bin/foo
- Bchmod o+rwx,a+rx /bin/foo
- Cchmod 577 /bin/foo
- Dchmod 775 /bin/foo
How the community answered
(31 responses)- A77% (24)
- B6% (2)
- C13% (4)
- D3% (1)
Why each option
To make a file executable by everyone but writable only by its owner, `chmod` can be used with the symbolic mode `u=rwx,go=rx`.
The command `chmod u=rwx,go=rx /bin/foo` sets read, write, and execute permissions for the user (owner), and only read and execute permissions for the group and others, ensuring only the owner can write to the file while everyone can execute it.
`o+rwx` would grant write permission to others, which violates the requirement that the file should be writable only by its owner.
`chmod 577` (r-x rwx rwx) grants write permission to both the group and others, contradicting the requirement for owner-only writability.
`chmod 775` (rwx rwx r-x) grants write permission to the group, which contradicts the requirement that the file should be writable only by its owner.
Concept tested: `chmod` symbolic and octal modes
Source: https://man7.org/linux/man-pages/man1/chmod.1.html
Topics
Community Discussion
No community discussion yet for this question.