How to Create a New sudo User in Ubuntu 20.04

Tutorial Dec 12, 2020

This tutorial will teach you how to create a new sudo user in any flavour of Ubuntu 20.04 desktop/server, without having to modify the /etc/sudoers file.


First, with the adduser command, we will create a new user (userb) on our system.

sudo adduser userb
Adding user `userb' ...
Adding new group `userb' (1002) ...
Adding new user `userb' (1002) with group `userb' ...
Creating home directory `/home/userb' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for userb
Enter the new value, or press ENTER for the default
        Full Name []: UserB
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] Y

Here, userb is the new user we are adding. replace it with the username you wish to add.


If we add a user to the sudo group, they can use the sudo command. We can use the usermod command to add the just created, or an existing user to the sudo group.

sudo usermod -a -G sudo userb

Again, userb is the example user we created in step 1. Replace it the username you wish to add to the sudo group.

Note: The -a (append) switch is important. If it is not used while running this command, userb will be removed from any group not listed after the -G switch.


In order to test the sudo powers of a user, first, we need to switch to that user. For that, we can use the su command.

su userb

We can do a simple test with the ls command to check if sudo is enabled for this user.

sudo ls -lah /root

If it gives out a permission denied output, make sure that you did step 2 properly. Else, you will be able to see the contents of the /root folder.



Simple, like quantum physics.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.