You want to temporarily change your primary group to another group of which you are a member.
In this process, a new shell will be created, and when you exit the shell, your previous group will
be reinstated. Which of the following commands will you use to accomplish this task?
A.
chmod
B.
newgrp
C.
chgrp
D.
chown
Explanation:
According to the scenario, you will use newgrp command to accomplish the task. The newgrp
command is used to temporarily change the primary group of a user into another group of which
that user is a member. In this step, a new shell will be created, and when that user will exit from
the shell, his previous group will be reinstated. If no group is specified, the GID is changed to the
login GID.
Answer option C is incorrect. John will not use the chgrp command to accomplish his 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 D is incorrect. John will not use the chown command to accomplish his task. The
chown command is used to change the user and/or group ownership of each given file as
specified by the first non-option argument as follows: if only a user name (or numeric user ID) isgiven, that user is made the owner of each given file, and the file’s group is not changed.
If the user name is followed by a colon and a group name (or numeric group ID), with no spaces
between them, the group ownership of the files is changed as well.
The syntax of the chown command is as follows: chown [-R [ -H | -L | -P ]] [ -h ] owner[:group] file …Answer option A is incorrect.
The chmod command is used to change the access mode of a file. The syntax of the command is:
chmod who=permissions filename
Here, “who” refers to the owner of the file, group members, or other users, and permissions refers
to “rwx”.
For example, chmod 755 File.txt will give all access permissions to the owner and the read and
execute permissions to the group members and other users.