How to create a non-admin (sudo) user on Ubuntu
Add a New User Account
Create a new user account with the adduser command.
$ adduser example_user
Use a strong password for the new user. You can enter values for the user information, or press ENTER to leave those fields blank.
Add the User to the Sudo Group
Add the new user to the sudo group with usermod
.
$ usermod -aG sudo example_user
Switch to the new user
# su - example_user
Verify you are the new user with whoami
, then test sudo access with sudo whoami
, which should return root.
$ whoami
example_user
$ sudo whoami
[sudo] password for example_user:
root
The new user account is ready to use. As a best practice, use this sudo user for server administration. You should avoid using root for maintenance tasks.
One Comment