PrepAway - Latest Free Exam Questions & Answers

Which of the following commands will he use to accomplish the task?

John works as a Network Administrator for Perfect Solutions Inc. The company has a Linux-based
network. John is working as a root user on the Linux operating system. He wants to change the
group membership of the file foo to group bar. Which of the following commands will he use to
accomplish the task?

PrepAway - Latest Free Exam Questions & Answers

A.
chgrp foo bar

B.
chgroup bar foo

C.
chgrp bar foo

D.
chgroup foo bar

Explanation:

According to the scenario, John will use the chgrp bar foo command to accomplish the task. The
chgrp (from change group) command is used by unprivileged users to change the group
associated with a file. Unlike the chown command, chgrp allows regular users to change groups,
but only to one of which they are a member. The general syntax of the chgrp command is as
follows:
chgrp group target1 [target2 ..]
The group parameter indicates the new group with which the targets should be associated.
The target1 parameter indicates the files or directories for which the change should be made.
The target2 parameter indicates the optional additional files or directories for which the change
should be made.
For example:
The above command changes the group associated with ttt to ‘system’, provided the executing
user is a member of that group.
Answer option A is incorrect. In the chgrp command, first we write the group name and after that,
we write the file name. But here just the opposite is written, so this command will not give the
desired result.
Answer options D and B are incorrect. There is no such command as chgroup in Linux.


Leave a Reply