How to use the newgrp Command on Ubuntu 18.04 with Examples

programmer 1653351 640

This brief tutorial shows students and new users how to use the newgrp command on Ubuntu to configure a group membership with which a users can login with.

For example, if you update a group named developers, all members of that group will be able to login (on terminal) using the group name.

For students or new users looking for a Linux system to start learning on, the easiest place to start is Ubuntu Linux OS…. It’s a great Linux operating system for beginners.

Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices…

While learning Ubuntu, you will find that Linux isn’t so different than Windows and other operating systems in so many ways, especially when it comes to using the system to get work done.…

Both Ubuntu and Windows systems allow you to be productive, easy to use, reliable and enable you to install and run thousands of programs from gaming to productivity suite software for individuals and businesses.

However, when you’re learning to use and understand Ubuntu Linux, you should also learn how to use the command line to terminal. Most Linux users should be able to do some basic command line tasks. This tutorial is going to show you how….

When you’re ready to learn how to use the newgrp commands, follow the guide below:

About newgrp command:

The newgrp command lets you change to a new group ID (GID) while logged into your current working directory,  but access permissions are calculated according to the new real and effective group IDs.


The syntax is the rule and format of how the newgrp command can be used. These syntax options can be reordered, but a straight format must be followed.,.

Below is an example syntax of how to use the newgrp command.

newgrp [-] [group]


The command line options are switches or flags that determined how the commands are executed or controlled. they modify the behavior of the commands. they are separated by spaces and followed after the commands.

Below are some options of the newgrp command:

  [group]Replace [group]  Replace group with the group name you want to assume and login with.
     If a hyphen [ ] is used in the command, then the user current working environment will change, otherwise, the current working environment remains unchanged.
–helpDisplay a help message and exit.


Below are some examples of how to run and use the newgrp on Ubuntu Linux.

Simply run the newgrp to invoke it.

If you want to use the newgrp command login to the developers group, you simply run the commands below:


newgrp developers

When you run the above command and you are not a member of the developers group and not a root, then you’ll be prompted for a group password if your account doesn’t have a password assigned.

If you’re listed as member of the group and the group has a password assigned, then you won’t be prompted.

If there is no group password set, and the user is not listed as a member of the group, the user will be denied access.

If you’re root, then no prompted is presented.

If you want to use the newgrp command to log in to the group developers, and, if successful, re-initializes the user environment.


newgrp - developers

To test out, create a new group, then add your account to the group and enable group password.

sudo groupadd developers
sudo usermod -a -G developers richard
sudo gpasswd developers

After that, test the newgrp command

That’s it!

Congratulations! You have learned how to use the newgrp command on Ubuntu

You may also like the post below:

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.