The sudo command allows users to run programs with the security privileges of another user, by default, the root user.

First if all, the user should be created in the system if it doesn’t exists yet.

On Ubuntu systems, by default members of the group sudo are granted to sudo command access.

Once the user is created, from root user, or a user with sudo access, you have to execute this command to add the user to sudo group.

sudo usermod -a -G sudo username

After this, the user will have access to sudo command.

To check if it is working, log in the session of the new user:

su - username

and execute the command:

sudo whoami

The output should be “root”, so you confirm the access has been granted successfully.