LFCS · Question #868
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 is used to change file ownership, and the correct syntax to specify both user and group is user:group.
Question
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)
- B86% (25)
- C3% (1)
- D7% (2)
Why each option
The `chown` command is used to change file ownership, and the correct syntax to specify both user and group is `user:group`.
The `/` character is not the correct separator for specifying user and group with `chown`; it is typically used for directory paths.
The `chown` command uses the `user:group` (or `user.group`) syntax to specify both the new user owner and the new group owner for a file, so `chown dan:staff file.txt` correctly changes the ownership.
The `-u` and `-g` options are not valid or standard ways to specify the user and group owners directly for the `chown` command.
The `-g` option is not the correct syntax for specifying the group when changing both user and group with `chown`; the correct format is `user:group`.
Concept tested: File ownership `chown` command syntax
Source: https://man7.org/linux/man-pages/man1/chown.1.html
Topics
Community Discussion
No community discussion yet for this question.