nerdexam
GIAC

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.

Linux and Cryptography

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)
  • A
    74% (20)
  • B
    4% (1)
  • C
    7% (2)
  • D
    15% (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.

AnewgrpCorrect

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.

Bchgrp

chgrp changes the group ownership of files and directories, not the current user's active primary group.

Cchown

chown changes the user and/or group ownership of files and directories, not the current user's active group context.

Dchmod

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

#newgrp#Linux groups#primary group#shell commands

Community Discussion

No community discussion yet for this question.

Full GSEC Practice