CompTIA Linux+ Powered by LPI (LX0-103) — Question 46
Which of the following commands changes the ownership of file.txt to the user dan and the group staff?
Answer options
- A. chown dan/staff file.txt
- B. chown dan:staff file.txt
- C. chown -u dan -g staff file.txt
- D. chown dan -g staff file.txt
Correct answer: B
Explanation
The correct command to change the ownership of a file and its group is 'chown dan:staff file.txt', where the colon ':' specifies the user and group. Option A uses a forward slash, which is incorrect syntax for ownership changes. Option C uses separate flags for user and group, which is not necessary when specifying both in the standard way. Option D incorrectly uses the '-g' flag without the appropriate syntax for user and group together.