How to Create a Group and Add Users in Linux (Ubuntu) Using Terminal Commands

Tiempo de lectura: 2 minutos

Reading time: 2 minutes

Photo by John Tekeridis on Pexel

We are going to create a group called grupoDevCodeLight. To do this, we will use groupadd as shown below:

sudo groupadd grupoDevCodeLight

If prompted, enter the administrator (root) password. Now, we will verify that the group has been created successfully using the following command:

sudo cat /etc/group

At the end, grupoDevCodeLight should appear as one of the groups.

Now, to add a user to this group, we will use usermod and add the group to the user using the -aG option, as indicated in the manual:

sudo usermod -aG grupoDevCodeLight DevCodeLight

Finally, we will check again for all created groups. In this case, the user DevCodeLight will appear as a member of the grupoDevCodeLight group, as we can see in the image.

To learn how to create users with their home directory, click here

I hope this helps. Have a great day.

Leave a Comment