Creating a non-root user with sudo privileges couldn’t be any easier.
In this example, we’ll be using Ubuntu Server as our operating system but the process is pretty much the same for any Linux-based operating system.
Create a new non-root user
First, we’ll create a new user
sudo adduser trywithpi
Replace trywithpi with your preferred username.
Then, we’ll add the newly created user to the sudo group by using the following command
sudo adduser trywithpi sudo
To verify our changes, we can run
id trywithpi
If the response contains 27(sudo), you’ve successfully created a non-root user with sudo privileges.
That’s it.