How to Create User on Ubuntu Server
In this article, we will describe how to define user creation and root rights in our server with Ubuntu operating system.
To connect to your server, you need to follow the steps in the Remote Access to Your Instance article.
You can connect to your instance via
ssh -i <path/to/file.pem> <defaultusername>@<instance_public_ip>
Switch to root user to add user.
$ sudo su
Use the adduser command to add a new user to your instance.
# adduser <username>
Set the password for new user
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Follow the promts to set the new user's information. You can accept the defaults to leave all of this information blank.
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]
We need to add the user to the sudo group in order to give the root rights to the user we created.
# usermod -aG sudo <username>
Test sudo access on new user account:
# su <username>