Create a Linux user with sudo access

Create the group

The following command will create a group called debian with id 1100

addgroup --gid 1100 debian

Create the user

The following command will create a user with name debian, with userid 1100 and will belong to the group debian (1100)

adduser --home /home/debian --shell /bin/bash --uid 1100 --gid 1100 --disabled-password --quiet debian

When the terminal prompts to add user data, just hit Enter key until it finishes.

Delete the user

To delete the user and it's home directory run the following command:

deluser --remove-home -q debian

It might complain that perl is not installed. To install it just run apt-get install -y perl as root user.

Grant user sudo access

As root user run the following command

echo "myuser ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/myuser

Make sure that files in /etc/sudoers.d don't have any . or ~ characters in the name.

Later, if you want to remove the sudo access for the user, just delete it's file from /etc/sudoers.d/ directory.

It is best practice to grant sudo access by creating a file for each user in /etc/sudoers.d instead of adding an entry in /etc/sudoers file.