GSEC · Question #374
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…
The correct answer is A. newgrp. The newgrp command temporarily changes the user's primary group by spawning a new shell, and exiting that shell restores the original group membership.
Question
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?
Options
- Anewgrp
- Bchgrp
- Cchown
- Dchmod
How the community answered
(27 responses)- A74% (20)
- B4% (1)
- C7% (2)
- D15% (4)
Why each option
The newgrp command temporarily changes the user's primary group by spawning a new shell, and exiting that shell restores the original group membership.
newgrp starts a new shell session with the specified group set as the invoking user's primary group, provided the user is already a member of that group. Upon exiting the new shell, the user is returned to their original shell with the previous primary group reinstated.
chgrp changes the group ownership of files and directories, not the current user's active primary group.
chown changes the user and/or group ownership of files and directories, not the current user's active group context.
chmod modifies file and directory permission bits (read, write, execute), not group membership or active group sessions.
Concept tested: Linux newgrp command for temporary group switching
Source: https://man7.org/linux/man-pages/man1/newgrp.1.html
Topics
Community Discussion
No community discussion yet for this question.