Create a Sudo User on Ubuntu

The sudo command provides a mechanism for granting administrator privileges, which is available to the root user, to normal users. This guide will show you the easiest way to create a new user with sudo access on Ubuntu, without having to modify your server’s sudoers file. If you want to configure sudo for an existing user, simply skip to step 3.

Sudo User on Ubuntu

Steps to Create a New Sudo User

  • Log in to your server as the root user.
server$ ssh root@server_ip_address
  • Use the adduser command to add a new user to your system.
#adduser username

Set the new user’s password at the prompt. Make sure that you replace username with actual username which you would like to create.

Set password prompts:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

It will also ask you additional details. If you do not wish to enter, you can just hit enter key.

  • Use the usermod command to add the user to the sudo group.
# usermod -aG sudo username
  • Test sudo access on a new user account using the following commands:
# su - username
# sudo ls -la /root

First time, it will prompt to enter the password of the user. You will need to enter the username password. Now you should be able to execute the command with root privileges. Now you are done with how to create a Sudo User on Ubuntu.

Create a Sudo User on Ubuntu