This tutorial explains Linux “newgrp” command, options and its usage with examples.
Usage:
newgrp [-] [group]
With the “newgrp” command you can change the default group associated with your login id, assuming you are a member of multiple groups. For example if you are a member of the groups “x” and “y”, and “x” is your current default group, you can switch to the other group.
“Newgrp” changes the group identification of its caller. The same person remains logged in, and the current directory is unchanged, but calculations of access permissions to files are performed with respect to the new group ID. If no group is specified, the GID is changed to the login GID.
Related Files
/etc/passwd User account information. /etc/shadow Secure user account information. /etc/group Group account information. /etc/gshadow Secure group account information.
newgrp changes the current real group ID to the named group, or to the default group listed in /etc/passwd if no group name is given. newgrp also tries to add the group to the user groupset. If not root, the user will be prompted for a password if she does not have a password (in /etc/shadow if this user has an entry in the shadowed password file, or in /etc/passwd otherwise) and the group does, or if the user is not listed as a member and the group has a password. The user will be denied access if the group password is empty and the user is not listed as a member.
* To change group:
newgrp name_of_the_group
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Apply for Programming Internship
- Apply for Linux Internship
- Buy Information Technology Books
- Practice Programming MCQs
- Buy Linux Books