newgrp Command in Linux


This tutorial explains Linux “newgrp” command, options and its usage with examples.

“newgrp” command in Linux is used to log in to a new group. This post describes “newgrp” command used in Linux along with usage examples and/or output.

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

    User account information.
    Secure user account information.
    Group account information.
    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.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.


Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.