Create the user
To create a linux user in Ubuntu 20.04 LTS run the following command as root:
adduser myuser -q --disabled-password
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-all-files -q myuser
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.