LFCS · Question #743
Which of the following commands makes /bin/foo executable by everyone but writable only by its owner?
The correct answer is D. chmod 755/bin/foo. The chmod 755 /bin/foo command sets file permissions so the owner has read, write, and execute permissions (7), while group and others have read and execute permissions (5), satisfying the requirement.
Question
Options
- Achmod 557 /bin/foo
- Bchmod o+rwx.a+rx/bin/foo
- Cchown 557 /bin/foo
- Dchmod 755/bin/foo
How the community answered
(18 responses)- A6% (1)
- C6% (1)
- D89% (16)
Why each option
The `chmod 755 /bin/foo` command sets file permissions so the owner has read, write, and execute permissions (7), while group and others have read and execute permissions (5), satisfying the requirement.
`chmod 557` would make the file readable and executable by owner and group, but readable, writable, and executable by others, which is incorrect.
The syntax `o+rwx.a+rx` is incorrect; the correct syntax for adding permissions would be `o+rwx,a+rx`.
`chown` changes file ownership, not permissions, making it irrelevant to the question's requirement.
The `chmod` command with octal permissions 755 correctly sets the permissions for `/bin/foo`. The first digit '7' (binary 111) gives the owner read, write, and execute permissions, and the second and third digits '5' (binary 101) give the group and others read and execute permissions, making it executable by everyone but writable only by its owner.
Concept tested: Linux file permissions (chmod octal)
Source: https://learn.microsoft.com/en-us/windows-server/administration/linux-reference/linux-commands/chmod
Topics
Community Discussion
No community discussion yet for this question.