LX0-103 · Question #55
Which of the following commands changes the ownership of file.txt to the user dan and the group staff?
The correct answer is B. chown dan:staff file.txt. The chown command uses a colon-separated user:group syntax to change file ownership for both user and group in a single invocation.
Question
Which of the following commands changes the ownership of file.txt to the user dan and the group staff?
Options
- Achown dan/staff file.txt
- Bchown dan:staff file.txt
- Cchown -u dan -g staff file.txt
- Dchown dan -g staff file.txt
How the community answered
(29 responses)- A3% (1)
- B90% (26)
- C7% (2)
Why each option
The chown command uses a colon-separated user:group syntax to change file ownership for both user and group in a single invocation.
A forward slash is not a valid delimiter in chown syntax; only the colon character separates the user from the group name.
The standard chown syntax for simultaneously setting both owner and group is chown user:group file, where a colon delimiter separates the two values. Running chown dan:staff file.txt sets the owning user to dan and the owning group to staff exactly as required.
chown does not recognize -u or -g flags; those option letters belong to other utilities such as id or install, and passing them to chown results in an error.
chown does not support a -g flag in any form; mixing a positional username argument with this unsupported flag produces a syntax error.
Concept tested: chown user and group ownership change syntax
Source: https://man7.org/linux/man-pages/man1/chown.1.html
Topics
Community Discussion
No community discussion yet for this question.