Linux Foundation Certified System Administrator Exam: Change Ownership of a File

Change Ownership of a File to User dan and Group staff

Question

Which of the following commands changes the ownership of file.txt to the user dan and the group staff?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B

The correct command to change the ownership of file.txt to the user dan and the group staff is B. chown dan:staff file.txt.

Explanation: The chown command is used to change the owner and/or group of a file or directory. It can be used with different options and syntax, but in this case, we want to change both the user owner and group owner of file.txt.

The syntax for chown command is: chown [OPTION]... [OWNER][:[GROUP]] FILE...

Where:

  • [OPTION]... are optional arguments to modify the behavior of the command.
  • [OWNER] is the name of the new user owner.
  • [:] is used to separate the user owner and group owner.
  • [GROUP] is the name of the new group owner.
  • [FILE]... is the file or files to change ownership.

Option A (chown dan/staff file.txt) is incorrect because it uses a forward slash to separate the user owner and group owner instead of a colon. The correct syntax for the separator is a colon.

Option C (chown -u dan -g staff file.txt) is also incorrect because it uses the -u option to specify the user owner and the -g option to specify the group owner. While this is a valid way to use the chown command, it is not necessary to use both options in this case.

Option D (chown dan -g staff file.txt) is incorrect because it only specifies the user owner (dan) but not the group owner. We need to specify both the user owner and group owner to change both.

Therefore, the correct command to change the ownership of file.txt to the user dan and the group staff is: chown dan:staff file.txt