nerdexam
CompTIA

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.

GNU and Unix Commands

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)
  • A
    3% (1)
  • B
    90% (26)
  • C
    7% (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.

Achown dan/staff file.txt

A forward slash is not a valid delimiter in chown syntax; only the colon character separates the user from the group name.

Bchown dan:staff file.txtCorrect

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.

Cchown -u dan -g staff file.txt

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.

Dchown dan -g staff file.txt

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

#chown#file ownership#user#group

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice