Forrest logo
back to the newgrp tool

newgrp:tldr:8c7de

newgrp: Reset primary group membership to user's default group in `/etc/passwd`.
$ newgrp
try on your machine

The "newgrp" command in Linux is used to create a new shell session with a different group identity. It allows the user to switch to a different primary group temporarily.

Here's how the command works:

  1. Once you execute the "newgrp" command, the system prompts you to enter the name of the group you want to switch to.
  2. If you provide a valid group name, the system verifies if you have the necessary permissions to switch to that group.
  3. If the verification is successful, a new shell session is created with the specified group as the primary group.
  4. From this point forward, any new files or directories created will have their ownership set to the new group.
  5. The user's group membership and permissions for existing files and directories are not affected by the "newgrp" command.
  6. To return to the original group, you can simply exit the new shell session.

Note that the "newgrp" command is typically used in situations where a user needs temporary access to certain files or directories that are owned by a different group.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the newgrp tool