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

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.