4 – Creating User Accounts with Administrative Privileges

How To Create a Sudo User

The sudo command provides a mechanism for granting administrator privileges, ordinarily only 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 Raspian, without having to modify your server’s sudoers file. If you want to configure sudo for an existing user, simply skip to step 2.

Steps to Create a New Sudo User

  1. Use the adduser command to add a new user to your system.

    Be sure to replace username with the user that you want to create.

    • adduser username
    • Set and confirm the new user’s password at the prompt. A strong password is highly recommended!
      Set password prompts:
      Enter new UNIX password:
      Retype new UNIX password:
      passwd: password updated successfully
      
    • Follow the prompts to set the new user’s information. It is fine to accept the defaults to leave all of this information blank.
      User information prompts:
      Changing the user information for username
      Enter the new value, or press ENTER for the default
          Full Name []:
          Room Number []:
          Work Phone []:
          Home Phone []:
          Other []:
      Is the information correct? [Y/n]
      
  2. Use the usermod command to add the user to the sudo group.
    • usermod -aG sudo username

    By default, on Raspian, members of the sudo group have sudo privileges.

Source: https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart