How to Add User, Add Group, and Add a Group to Sudoers in Vagrant

We know that you have to be in your vagrant machine before you can decide on creating a user, or group or adding a group to sudoers. If you have not done this, kindly ssh into your machine. The process of adding users and groups is quite simple. Before we do this, we have to know this list of users and groups that we have in our machine. This can be gotten by typing,

cat /etc/passwd

The above command line will show you the list of users you have in your machine. You can also get the particular user you want with this;

```cat /etc/passwd | grep username


```cat /etc/group

The above command line will show you the list of groups you have in your machine. You can get the group you want to see with the below command line

```cat/etc/group | grep groupname


**Adding a user to your machine **

You can add a user to your machine by following the snippet below

```useradd name

If the permission is denied, switch to root user with ```sudo su

The try again. 

**Adding a group to your machine**

```groupadd name

Groups can be deleted using groupdel. It can be modified using groupmod.

How to add a group to sudoers

This is an important and sensitive part of a vagrant machine. If this is done wrongly, it can destroy the machine and you will lose your work to a mere mistake. So, you have to be really careful when it comes to this part of work. Follow the list below and you will not be in trouble.

  1. visudo /etc/sudoers

4.PNG The above image is what you should see on your screen.

  1. Make your way to the last line, you can comment what you want, this will make us understand what you did when you refer back to the folder. Then type

%groupname ALL=(ALL:ALL) ALL

5.PNG

  1. Press ctrl O.

You have successfully added a group to sudoers.

Ensure that you replace anywhere i used groupname or username to the desired name you want.