How to create a new Sudo User on Ubuntu.

In this article, we are going to show you how to create a new sudo user on Ubuntu.

As you probably already know, sudo is a useful command that allows you to carry out important actions.

If a user isn’t root and they aren’t present in the “sudoers file”, then they will be unable to run certain commands.

1. Make sure that you have sudo privileges.

This might seem obvious, but we will state it anyway.

To create a new sudo user, you must be logged in as “root” or as an existing sudo user.

Basically, if you don’t have administrative privileges, then you will not be able to create a sudo user.

2. Create the new user.

To create a new user, simply enter the following command:

sudo adduser wayne

Above, we used the adduser command to create a new Ubuntu user called “wayne”.

After you enter this command, Ubuntu will ask you to fill out personal details about this person.

However, these details are not important, so you can just enter whatever you want to.

3. Add the new user to your sudoers list.

To add the user to our sudoers file, we will use the usermod command:

sudo usermod -aG sudo wayne

By adding the user to this group, we are basically giving them the ability to use the sudo command.

4. Test their privileges.

At this stage, we will need to confirm that it actually worked.

To test the privileges of our new user, we will need to switch accounts:

su - wayne

In this case, the hyphen is important as it tells Ubuntu that you want to adopt the user’s environment.

Once you have successfully switched accounts, you can test out the privileges by creating a test file:

sudo touch /home/wayne/test.txt

When you run the command above, Ubuntu will prompt you to enter your password:

[sudo] password for wayne:

And that’s it!

Enter your password and the command should run under sudo privileges. If it doesn’t work, then it means that you have probably made a mistake during one of the steps above.