Newgrp
lastmod 2024-01-03created 2024-01-031 edits
Changes the user's real group ID.
About
The newgrp command changes a user's real group ID. When you run this command, the system places the user in a new shell and changes the user's real group name to the group specified by the Group parameter. By default, the newgrp command changes the user's real group to the group specified in the /etc/passwd file.
| WARNING |
| The newgrp command does not read input from standard input and cannot be run within a script. |
The newgrp command does not recognize group IDs; it recognizes only group names. Changes apply only to the current session. Users can change their real group only to a group they are already a member of. The root user can change the real group to any group, regardless of membership.
| WARNING |
| When you run the newgrp command, the system always replaces the user's shell with a new shell. This command replaces the user's shell regardless of whether it succeeds. For this reason, this command does not return an error code. |